OStack程序员社区-中国程序员成长平台

标题: ios - 购买产品时的应用内购买问题 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 17:06
标题: ios - 购买产品时的应用内购买问题

点击按钮后,我正在应用内购买 (多次显示我的测试用户的登录警报)

- (IBAction)BuyProductid)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

请帮忙!



Best Answer-推荐答案


这可能对你有用:

- (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];
    }
}

关于ios - 购买产品时的应用内购买问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20425485/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4