0

我通过 本教程使用 IAP 制作了我的第一个应用程序

我为 InAppPurchaseManager 制作了一个单例,增加了 3 次购买,为他们添加了方法,一切都很好。问题是我的应用程序是一个画廊,其中用户有 9 件免费物品,之后有 18 件物品付费。我如何ViewController在系统显示时检查我的购买是否成功UIAletrView?或者也许我可以在我的ViewController?

对于我正在使用的画廊UICollectionView,如果购买完成,我需要重新加载它

4

1 回答 1

0

You can check the status of the transaction by using this delegate method..

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{

    for (SKPaymentTransaction *transaction in transactions)
    {
        NSLog(@"%i",[transaction transactionState]);
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                // [self completeTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                // [self failedTransaction:transaction];
                break;
            case SKPaymentTransactionStateRestored:
                // [self restoreTransaction:transaction];
            case SKPaymentTransactionStatePurchasing: {
                // if([self.delegate respondsToSelector:@selector(inProcessPurchasingTransaction)])
                // [self.delegate inProcessPurchasingTransaction];
                }
            default:
                break;
        }
    }
}

And the following delegate method will fire when the transaction success :

 - (void) completeTransaction: (SKPaymentTransaction *)transaction

And in case of fail :

- (void) failedTransaction:(SKPaymentTransaction *)transaction

And for a testing purpose you need to create test user accounts. After you program the app, you might want to test the app. You can use these accounts to login to the App Store. The purchases will be processed as if it were real but no financial transactions will take place.

于 2013-02-04T10:45:39.410 回答