【发布时间】:2013-03-27 14:30:45
【问题描述】:
我正在使用应用内购买功能为 iPhone 和 iPad 创建一个应用,但是我在 iPhone 上遇到了问题。当我点击我的可购买物品之一时,一旦将SKPayment 添加到SKPaymentQueue,我的 ViewController 就会自行关闭,使付款未处理。在我将[[SKPaymentQueue defaultQueue] removeTransactionObserver:self] 添加到我的dealloc 之前,这会导致崩溃。
一旦我重新启动该应用程序,它将按预期处理付款并授予用户他们购买的内容。除非完全退出并重新启动,否则它不会处理付款。
我添加付款的方式如下:
- (void)purchaseConnector: (NSIndexPath *)indexPath
{
SKProduct *selectedProduct = productDetailsList[indexPath.row];
SKPayment *payment = [SKPayment paymentWithProduct:selectedProduct];
[[SKPaymentQueue defaultQueue] addPayment:payment];
}
之后它进入这里:
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
{
for (SKPaymentTransaction *transaction in transactions)
{
switch (transaction.transactionState)
{
case SKPaymentTransactionStatePurchased:
[self completeTransaction:transaction];
break;
case SKPaymentTransactionStateFailed:
[self failedTransaction:transaction];
break;
case SKPaymentTransactionStateRestored:
[self restoreTransaction:transaction];
break;
default:
break;
}
}
}
事务的状态是 SKPaymentTransactionStatePurchasing 并因此继续,之后 ViewController 关闭并弹出“确认您的应用内购买”UIAlert。
再一次,在 iPad 上一切正常,这些问题只在 iPhone 上出现。
编辑
我想澄清一下,问题是商店 ViewController 正在解散。我自己从不忽略它,而且似乎无法通过它接收该命令的位置。解雇不会在 iPad 上发生,只是在 iPhone 上发生。
【问题讨论】:
标签: iphone ios in-app-purchase