iOS 消耗内购重复购买注意点
2023-02-28 本文已影响0人
凤毛麟角0712
// 13.监听购买结果
-
(void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transaction{
for(SKPaymentTransaction *tran in transaction){switch (tran.transactionState) { case SKPaymentTransactionStatePurchased: NSLog(@"交易完成"); [[SKPaymentQueue defaultQueue] finishTransaction:tran]; break; case SKPaymentTransactionStatePurchasing: NSLog(@"商品添加进列表"); break; case SKPaymentTransactionStateRestored: NSLog(@"已经购买过商品"); [[SKPaymentQueue defaultQueue] finishTransaction:tran]; break; case SKPaymentTransactionStateFailed: NSLog(@"交易失败"); [[SKPaymentQueue defaultQueue] finishTransaction:tran]; break; default: break; }
}
}
就是 [[SKPaymentQueue defaultQueue] finishTransaction:tran];除了 case SKPaymentTransactionStatePurchasing:
NSLog(@"商品添加进列表");
break;
这里不需要之外都要加入的。
不然在你重复购买的时候就会提示你已经购买过的提示框了