1

当应用内购买恢复时,会调用以下委托方法:

-(void)paymentQueueRestoreCompletedTransactionsFinished:(SKPaymentQueue *)queue {

    NSLog(@"%@", queue.transactions);

    for (SKPaymentTransaction *transaction in queue.transactions) {

        //restore

    }

}

有很多事务,queue.transactions而只有一个产品被恢复(在这个例子中,有超过 20 个事务写入日志)。为什么?不应该只有一笔交易吗?如果我开始从我的服务器下载产品,它会下载 20 次,因为阵列中的事务太多!

在此处输入图像描述

4

1 回答 1

1

您应该在方法中处理事务paymentQueue:updatedTransactions:。在paymentQueueRestoreCompletedTransactionsFinished:那里告诉你它已经完成了。

- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions {
    for (SKPaymentTransaction *transaction in transactions)
    {
        switch (transaction.transactionState)
        {
            case SKPaymentTransactionStatePurchased:
                // process purchase
                break;
            case SKPaymentTransactionStateFailed:
                // process error
                break;
            case SKPaymentTransactionStateRestored:
                // process restored IAP
                break;
        }
    }
}
于 2012-12-21T21:56:03.777 回答