问题描述
我的问题基本上是如何重现我在应用商店中的其他应用中有关应用内购买的行为:
My question is basically how to reproduce the behavior I see in other apps in the app store with regards to in-app purchases:
- 在用户按下购买"后立即隐藏该按钮,并显示微调框(基本上取消了购买"动作的反跳).
- 用户在应用程序内或外部的StoreKit对话框中按取消"会导致微调框消失.
我正在尝试通过观察SKPaymentQueue中的交易状态来显示和隐藏微调器.
I'm attempting to show and hide the spinner based on observing the state of transactions in the SKPaymentQueue.
此海报描述了我的问题:
My problem is described by this poster:
在应用内购买"中,用户在后台运行时取消了发送:发送状态保持为购买状态
无论测试用户是否先登录,我都会看到与上述帖子相同的行为.交易基本上被卡住"在队列中,并且永远处于购买状态(这意味着我的微调器将永远显示).当应用程序完全退出并重新启动(而不仅仅是完成多任务处理)后,交易不再在支付队列中,因此显然不是真正还在购买.就像SKPaymentQueue错过了"状态更改一样.
I see the same behavior as the post above regardless of if the test user is logged in first or not. The transaction is basically "stuck" in the queue with a purchasing state forever (meaning my spinner is displayed forever). When the app is completely exited and restarted (not just multi-tasked away) the transaction is no longer in the payment queue so it's clearly not really still purchasing. It's like the SKPaymentQueue "missed" the state change.
我注意到的更多细节是,在典型情况下,添加付款后,交易立即显示在具有购买状态的队列中.如果用户按取消",则事务状态将失败.
Some more detail that I've noticed is that in the typical case, immediately after adding the payment, the transaction shows up in the queue with a purchasing state. If the user presses cancel, the state of the transaction goes to failed.
在添加付款后立即执行任务的情况下,直到任务重新分配给应用程序后,交易才会显示在队列中.与其看到两次对updatedTransactions委托的调用(一个处于购买状态,一个处于失败状态),却只看到一个对具有购买状态的updatedTransactions委托的调用.事务永远不会失败.
In the case of tasking away immediately after adding the payment, the transaction does not show up in the queue until tasking back to the app. Instead of seeing two calls to the updatedTransactions delegate (one with a state of purchasing and one with a state of failed) there is only one call to the updatedTransactions delegate with a state of purchasing. The transaction never goes to failed.
偶尔,当任务返回到应用程序时,我会得到一个删除交易的回调(在看到带有购买状态的updatedTransaction之后).即使在这种情况下,我也从未看到预期的事务更新到失败状态.
Very occasionally, when tasking back to the app I will get a transaction removed callback (after seeing the updatedTransaction with a state of purchasing). Even in this case I never see the expected update of the transaction to the failed state.
我无法在应用商店中的应用中重现此行为(无论是否执行任务,它们始终正确显示/隐藏微调框),但是我不清楚这是否是因为它们在做一些棘手的事情,或者如果只是沙盒中的问题.
I am not able to reproduce this behavior in apps in the app store (they always correctly show/hide the spinner regardless of tasking away or not), but it's not clear to me if that's because they are doing something tricky, or if it's only a problem in the sandbox.
如果不通过监视事务状态来如何复制此行为?在生产中这不是问题吗?
How to replicate this behavior if not by monitoring the state of the transaction? Is this not a problem in production?
谢谢!
推荐答案
我已经使用 MKStoreKit 我的应用.
它具有一个基于块的界面,可告诉您交易何时开始(隐藏按钮并开始动画处理).
It has a block based interface that tells you when the transaction has started (To hide the button and start animating).
它还会告诉您交易是否失败或竞争,因此您可以停止动画并恢复按钮(如果失败)或在完成时显示其他内容.
It will also tell you if the transaction fails or it was competed, so you can stop the animation and restore the button (if it failed) or show something else when it is completed.
由于它使用了块,因此您无需编写大量样板代码就可以处理所有这些行为.
Because it uses blocks, you can handle all this behavior without writing a lot of boilerplate code.
这篇关于多任务处理和SKPaymentQueue我被“卡住"了带有SKPaymentTransactionStatePurchasing的transactionState的SKPaymentTransaction的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!