点击按钮后,我正在进行In app购买 (多次显示我的测试用户的登录提醒)
- (IBAction)BuyProduct:(id)sender {
SKPayment *payment = [SKPayment paymentWithProduct:_product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
然后代码移至
case SKPaymentTransactionStateFailed:NSLog(@"Transaction Failed");
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
最后我的控制台显示:
2013-12-06 18:56:13.694 sample_purchase[505:60b] Transaction Failed
2013-12-06 18:56:20.553 sample_purchase[505:60b] <SKPaymentQueue: 0x166809c0>: Ignoring restoreCompletedTransactionsWithApplicationUsername: because already restoring transactions
2013-12-06 18:56:21.844 sample_purchase[505:60b] <SKPaymentQueue: 0x166809c0>: Ignoring restoreCompletedTransactionsWithApplicationUsername: because already restoring transactions
请帮忙!
答案 0 :(得分:1)
这对您有用:
- (void)restoreCompletedTransactions {
if ([[[SKPaymentQueue defaultQueue] transactions] count]) {
NSLog(@"We get very non-patient user");
for (SKPaymentTransaction *transaction in [[SKPaymentQueue defaultQueue] transactions])
[[SKPaymentQueue defaultQueue] finishTransaction:transaction];
}else{
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
}
}