iPhone 应用内购买:如何使用 storekit 检测未完成的交易?
我正在 iPhone 应用程序中实现应用内购买,该应用程序允许下载大量数据。
现在,我试图弄清楚商店工具包是否可以告诉我是否有任何交易已完成购买,但已因应用程序关闭而中断。
据我所知,执行此操作的唯一方法是将观察者添加到 SKPaymentQueue:
[[SKPaymentQueue defaultQueue] addTransactionObserver:someObject];
并等待 defaultQueue 调用
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
someObject。当此方法是时,处于上述中断状态的项目在交易数组中显示为 SKPaymentTransactionStatePurchased
我解决此问题的第一次尝试是添加我的观察者,然后要求:
[SKPaymentQueue defaultQueue].transactions
并检查它们。据称,这会返回一组“待处理”交易,但根据我的经验,不包括 SKPaymentTransactionStatePurchased 中的交易。
我希望使用 storekit 来维持这种状态,并且喜欢任何想法。谢谢。
I'm implementing in-app purchase in an iphone application that allows for downloading of a non-trivial amount of data.
Right now, I'm trying to figure out if the Store Kit can tell me if there are any transactions where the purchase is complete, but that have been interrupted by application shutdown.
As far as I can tell the only way to do this is to add an observer to the SKPaymentQueue:
[[SKPaymentQueue defaultQueue] addTransactionObserver:someObject];
and wait for the defaultQueue to call
- (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions
on someObject. Items that are in the interrupted state above show up in the transactions array as SKPaymentTransactionStatePurchased when this method is
My first attempt at solving this problem was to add my observer and then ask for:
[SKPaymentQueue defaultQueue].transactions
and inspect those. This allegedly returns an array of 'pending' transactions, but in my experience doesn't include transactions that are in SKPaymentTransactionStatePurchased.
I was hoping to use the storekit to maintain this state and would love any ideas. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为单独使用商店套件不可能做到这一点,所以我在 sqlite 中制作了一个小表:
当我收到 SKPaymentQueue 回调表明产品已购买时,我向该表添加一行。
它工作得很好。
I decided that it was impossible to do this using store kit alone so I made a small table in sqlite:
and when I get the SKPaymentQueue callback indicating that a product has been purchased I add a row to this table.
It's working just fine.