我为 InAppPurchaseManager 制作了一个单例,增加了 3 次购买,为他们添加了方法,一切都很好。问题是我的应用程序是一个画廊,其中用户有 9 件免费物品,之后有 18 件物品付费。我如何ViewController
在系统显示时检查我的购买是否成功UIAletrView
?或者也许我可以在我的ViewController
?
对于我正在使用的画廊UICollectionView
,如果购买完成,我需要重新加载它
我为 InAppPurchaseManager 制作了一个单例,增加了 3 次购买,为他们添加了方法,一切都很好。问题是我的应用程序是一个画廊,其中用户有 9 件免费物品,之后有 18 件物品付费。我如何ViewController
在系统显示时检查我的购买是否成功UIAletrView
?或者也许我可以在我的ViewController
?
对于我正在使用的画廊UICollectionView
,如果购买完成,我需要重新加载它
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.