应用程序内购买:正确处理finishTransaction

时间:2014-07-10 18:14:45

标签: objective-c ios7 in-app-purchase

我遇到了一些用户支付In-App-Purchase的问题,但应用程序没有对此作出反应;因此我的问题是这样处理是否正确:

- (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究竟做了什么?它应该仅在成功案例中被调用吗?

0 个答案:

没有答案