我已经实施了Apple文档中描述的关于IAP的应用程序内付款,但是当我在沙盒模式下尝试它们时,'transactionState'将永远不会更改为SKPaymentTransactionStatePurchased。 (它永远停留在SKPaymentTransactionStatePurchasing上。)
有人知道出了什么问题吗?
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
NSLog(@"%ld", transaction.transactionState);
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
default:
break;
}
}
}
- (void)completeTransaction:(SKPaymentTransaction *)transaction
{
[self recordTransaction:transaction];
[self provideContent:transaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
- (void)failedTransaction:(SKPaymentTransaction *)transaction
{
if (transaction.error.code != SKErrorPaymentCancelled) {
[NSAlert alertWithError:transaction.error];
}
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
- (void)restoreTransaction:(SKPaymentTransaction *)transaction
{
[self recordTransaction:transaction];
[self provideContent:transaction.originalTransaction.payment.productIdentifier];
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}
- (void)recordTransaction:(SKPaymentTransaction *)transaction
{
NSLog(@"Record Transaction...");
// ToDo: Implement 'recordTransaction'.
}
- (void)provideContent:(NSString *)productIdentifier
{
NSLog(@"Provide Content");
// ToDo: Implement 'provideContent'.
}
答案 0 :(得分:0)
在不同的计算机上测试相同的代码。它适用于我的开发机器。似乎不是我的代码。