iphone - 苹果因应用内购买未实现恢复而拒绝

标签 iphone objective-c in-app-purchase restore

<分区>

我被 Apple 拒绝了,消息说:

... 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. ...

我找到了这个 page ,我按照示例代码操作,但在调用

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

另一位代表没有被解雇!

- (void) paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue

它只弹出一个警告 View ,让您输入您的 Apple ID ...但什么也没发生?

我设置了一个断点,但是它并没有像例子中说的那样停止。

对我的代码有什么问题有什么想法吗?

最佳答案

除了添加 restoreCompletedTransactions 之外,您还需要处理如何将 iaps 实际恢复给用户以及如何将内容提供给用户。

基本上,您需要回想一下您在用户最初购买商品时向其提供商品的方式。

Here is a good tutorial.

例如,这是我在我的一个应用程序中恢复产品的方式。

恢复交易

- (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];
}

交易完成

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

支付队列

- (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;
        }
    }
}

提供内容

- (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];
}

关于iphone - 苹果因应用内购买未实现恢复而拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11200460/

相关文章:

ios - 在 Swift 中的 cellForRowAtIndexPath 中的 UITableView 中选择检测单元格

当didUpdateToLocation发生时,iphone在后台发送邮件

ios - productsRequest 不适用于应用内购买

ios - 应用程序加载器应用内购买导入消失

iphone:在将条目添加到可变字典中 setObject:forKey: 和 setValue:forKey: 有什么区别

ios - 是否有可能永远不会在线程中调用延迟调用?

objective-c - 可以发现已编译的 Obj-C 应用程序中的 "secret"字符串吗?

objective-c - 为DSP目的在C++中处理音频数据

in-app-purchase - 通过应用内购买 (IAP) 捐赠

iphone - ios objective C Bool 未设置