Objective c 应用内购买:正确处理finishTransaction

Objective c 应用内购买:正确处理finishTransaction,objective-c,ios7,in-app-purchase,Objective C,Ios7,In App Purchase,我有一个问题,一些用户支付了应用程序内的购买费用,但应用程序对此没有反应;因此,我的问题是这样处理是否正确: - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions { for (SKPaymentTransaction *transaction in transactions) { switch (transaction.transactionSta

我有一个问题,一些用户支付了应用程序内的购买费用,但应用程序对此没有反应;因此,我的问题是这样处理是否正确:

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions) {
        switch (transaction.transactionState) {
            case SKPaymentTransactionStatePurchasing:
                break;
            case SKPaymentTransactionStatePurchased:
                [self handlePurchase]; // seems like this isn't called sometimes

                // Remove the transaction from the payment queue.
                [queue finishTransaction:transaction];
                break;
            case SKPaymentTransactionStateFailed:
                // Remove the transaction from the payment queue.
                [queue finishTransaction:transaction];

                [self handleCancel];
                break;
            case SKPaymentTransactionStateRestored:
                [self handlePurchase]; // or this isn't called someimtes

                // Remove the transaction from the payment queue.
                [queue finishTransaction:transaction];
                break;
            default:
                break;
        }
    }
}

这样队列处理是否正确?
finishTransaction
具体做什么?是否应仅在成功案例中调用它?

是的,您必须在所有案例中调用
finishTransaction
。-您是否记得将此对象作为付款观察员?你有什么证据证明有问题?你不是在模拟器上测试,是吗?这不起作用…来自SKPaymentQueue.h://异步。从队列中删除已完成(即失败或已完成)的事务。试图完成采购事务将引发异常。--因此,您不将其称为采购交易是正确的。您的switch语句应该是正确的。