我正在为 ma iOS 应用编写应用内购买功能。我在卖一些简单的消耗品(没有下载)。我的代码基于本教程/主题 How do you add an in-app purchase to an iOS application? 但是我注意到它与苹果官方文档冲突。
在这段代码中,当交易因任何原因失败时,这段代码 [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 叫做。但是在苹果页面上 https://developer.apple.com/library/ios/documentation/StoreKit/Reference/SKPaymentQueue_Class/Reference/Reference.html#//apple_ref/occ/instm/SKPaymentQueue/finishTransaction : 这个已经写完了: “您的应用程序应该调用 finishTransaction:只有在成功处理交易并解锁用户购买的功能后。”
那么哪种做法是正确的呢?我应该对失败的交易调用 finish 吗?
最佳答案
根据 Apple 的 In-App Purchase Programming Guide
Your app needs to finish every transaction, regardles of whether the transaction succeeded or failed.
因此无论交易结果如何,您总是完成交易以将其从支付队列中移除,然后在您的代码中处理状态(成功或失败)以便为用户提供适当的信息
关于ios - 我应该在应用内购买期间对失败的交易调用 finishTransation 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24654241/