我正在为iOS应用程序编写应用内购买功能 . 我正在销售一些简单的消耗品(没有下载) . 我的代码基于这个教程/主题How do you add an in-app purchase to an iOS application?但是我注意到它与官方苹果文档冲突 .
在此代码中,当一个Transaction因任何原因失败时,此代码[[SKPaymentQueue defaultQueue] finishTransaction:transaction];叫做 . 但是在Apple页面https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentQueue_Class/Reference/Reference.html#//apple_ref/occ/instm/SKPaymentQueue/finishTransaction:它写道:"Your application should call finishTransaction: only after it has successfully processed the transaction and unlocked the functionality purchased by the user."
那么哪种方法是正确的?我应该在失败的交易上致电完成吗?
1 回答
根据Apple的In-App Purchase Programming Guide
因此,无论事务结果如何,您始终完成事务以将其从支付队列中删除,然后处理代码中的状态(成功或失败),以便为用户提供适当的信息