Apple reject because of In app purchase not implement restore [closed]

烂漫一生 提交于 2019-11-28 16:52:45

问题


I got rejected by Apple with a message saying:

... Additionally, we found that while your app offers In-App Purchase(s) that can be restored, it does not include the required "Restore" feature to allow users to restore the previously purchased In-App Purchase(s), as specified in Restoring Transactions section of the In-App Purchase Programming Guide:

"...if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases. This interface allows a user to add the product to other devices or, if the original device was wiped, to restore the transaction on the original device."

To restore previously purchased In-App Purchase products, it would be appropriate to provide a "Restore" button and initiate the restore process when the "Restore" button is tapped by the user.

For more information about restoring transactions and verifying store receipt, please refer to the In-App Purchase Programming Guide. ...

And I found this page, and I followed the sample code , but after I called

- (void) checkPurchasedItems{
   [[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}

another delegate was not fired!

- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

It only popups an alert view, to let you enter your Apple ID ... and nothing happened?

I set a break point, but it wouldn't stop as the example said.

Any ideas on what's wrong with my code?


回答1:


In addition to adding restoreCompletedTransactions, you need to handle how your iaps are actually restored to the user and how the content is provided to the user.

Basically, you need to recall the way you provide the item to your user when they originally purchased it.

Here is a good tutorial.

For example, this is how I restore products in one of my apps.

Restore Transaction

- (void)restoreTransaction:(SKPaymentTransaction *)transaction
{
    isRestoring = YES;

    [self recordTransaction: transaction];

    /* This is where I provide the content to the user: */
    [self provideContent: transaction.originalTransaction.payment.productIdentifier];

    [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

Transaction Completed

- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
    [self recordTransaction: transaction];
    [self provideContent: transaction.payment.productIdentifier];
    [[SKPaymentQueue defaultQueue] finishTransaction: transaction];
}

Payment Queue

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                if (transaction.error.code == SKErrorPaymentCancelled) {
                    /// user has cancelled
                    [[NSNotificationCenter defaultCenter] postNotificationName:@"hideRestoring" object:nil];
                }
                [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                [self restoreTransaction:transaction];
            default:
                break;
        }
    }
}

Provide the Content

- (void)provideContent:(NSString *)productIdentifier
{
    int index;

    NSMutableDictionary * purchased = [NSMutableDictionary dictionaryWithContentsOfFile:EXTRAS_PATH];

    NSArray * availableProducts = [NSArray arrayWithContentsOfURL:[NSURL URLWithString:SCANNER_IN_APP_PURCHASES]];

    if ( isRestoring )
    {
        for ( index = 0; index < [availableProducts count]; index++ )
        {
            //NSLog(@"productIdentifier: %@",productIdentifier);
            //NSLog(@"Product: %@",[availableProducts objectAtIndex:index]);

            if ( [productIdentifier isEqualToString:[[availableProducts objectAtIndex:index] objectForKey:@"BundleID"]] )
            {
                [purchased setObject:[availableProducts objectAtIndex:index] forKey:productIdentifier];

                [purchased writeToFile:EXTRAS_PATH atomically:YES];

                [_purchasedProducts addObject:productIdentifier];
            }
        }
    }
    else
    {
        index = [[[NSUserDefaults standardUserDefaults] objectForKey:@"kTempProductPurchasingIndex"] intValue];

        if ( [productIdentifier isEqualToString:[[availableProducts objectAtIndex:index] objectForKey:@"BundleID"]] )
        {
            [purchased setObject:[availableProducts objectAtIndex:index] forKey:productIdentifier];

            [purchased writeToFile:EXTRAS_PATH atomically:YES];

            [_purchasedProducts addObject:productIdentifier];
        }
    }

    [[NSNotificationCenter defaultCenter] postNotificationName:kProductPurchasedNotification object:productIdentifier];
}



回答2:


[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];

Add The previous line as well. Your paymentQueueRestoreCompletedTransactionsFinished function should get called.



来源:https://stackoverflow.com/questions/11200460/apple-reject-because-of-in-app-purchase-not-implement-restore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!