2
我正在實施應用程序購買。一切都很順利,但我的流程總是停在SKPaymentTransactionStatePurchasing:有人知道它的原因嗎?請幫忙。申請流程停止在SKPaymentTransactionStatePurchasing
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
NSLog(@"transactions........%@",transactions);
NSLog(@"transactions count........%d",[transactions count]);
NSLog(@"transactions description ........%@",transactions.description);
[[SKPaymentQueue defaultQueue] removeTransactionObserver:self];
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
[[SKPaymentQueue defaultQueue] finishTransaction: transaction];
break;
case SKPaymentTransactionStatePurchasing:
NSLog(@"purchasing");
// [self completeTransaction:transaction];
break;
default:
NSLog(@"default case");
break;
}
}
}
有時最好不要刪除觀察者。例如:當用戶開始購買並在其中間時,他被要求更新他的信用卡信息,他被轉移到設置應用程序,並且在更新成功後,他可以在你的應用程序之外完成購買過程。當回到您的應用程序時,它會收到2個連續的交易,一個失敗的,然後是成功的。在這種情況下,您不希望在失敗的事務之後立即刪除觀察者,並錯過成功的事務。 – Got99Errors