SKPaymentTransactionObserver 在应用程序切换时未收到回调
我设置了应用内购买,以便当用户单击购买按钮时,会出现“请稍候”视图并将付款添加到付款队列中。这总是会导致队列观察者立即回调,表示交易进入“购买”状态。
当用户在弹出确认购买对话框之前返回主屏幕然后取消时,就会出现我的问题。如果我在主屏幕上等待一段时间然后再切换回应用程序,则应用程序永远不会收到有关事务切换状态或被删除的任何回调。如果我检查支付队列,我可以看到交易仍在队列中,仍处于“购买”状态。在恢复应用程序后,我可以做些什么来使其回调并将其从队列中删除?
I have in-app purchases set up so that when a user clicks on the buy button, a "Please Wait" view appears and adds a payment to the payment queue. This always causes an immediate callback of the queue's observer saying that the transaction entered the "Purchasing" state.
My problem happens when the user returns to the main screen before the confirm to purchase dialog pops up, then cancels. If I wait around on the main screen awhile before switching back to the application, the application never gets any callback about the transaction switching state or being removed. If I examine the payment queue, I can see that the transaction is still in the queue, still in the "Purchasing" state. Is there anything I can do to make it call back and remove it from the queue after resuming the application?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解您的情况,那么您遇到了此问题:
在应用程序购买中,用户在应用程序处于后台时取消交易:交易状态保持在购买状态
这似乎是 Apple Store 套件中的一个错误。如果您在开始购买后立即将应用程序发送到后台,然后在提示购买确认弹出窗口时按取消按钮,则可以轻松重现该问题。您的应用程序永远不会收到交易失败(取消)通知,并将进入阻止状态(如果您禁用了 UI,试图阻止用户在购买完成之前与应用程序交互)。
我们必须等待苹果的修复。同时,如果您的应用程序因您在购买时禁用 UI 而进入阻止状态;您应该实现某种机制来允许用户离开该状态。
祝你好运!
If I understood your situation correctly, you've encountered this problem:
In App Purchase user cancels tx while app in background: tx state stays on purchasing
This appears to be a bug in Apple's Store kit. The issue can easily be reproduced if you send your app to background right after initiating a purchase and then pressing the cancel button when the buy confirmation popup is prompted. Your app will never receive the transaction failed(cancelled) notification and will enter a blocked state (if you disabled the UI trying to prevent the user from interacting with the app until the purchase has finished).
We have to wait for a fix from Apple. In the meantime, if your app is entering a blocked state because you disable UI while making a purchase; you should implement some mechanism to allow the user to leave that state.
Good luck!
我有同样的问题,但是,我只能在使用沙箱应用程序商店帐户时重现它。
有人设法使用真实的苹果帐户重现它吗?
我还没有尝试过这个,但我正在考虑在应用程序失去焦点时删除我的 SKPaymentTransactionObserver,并在下次激活时再次添加它。
关于此错误的奇怪之处在于,您会陷入购买状态下的交易,但是当您正确关闭应用程序并重新启动它时,您会期望购买状态下的交易仍然存在,但事实并非如此。 .. 好像重新添加 SKPaymentTransactionObserver 已触发它正确地重新评估其状态。
I have the same problem, however, I have only managed to reproduce it when using a sandbox appstore account.
Has anyone managed to reproduce it using a real apple account?
I've not tried this yet, but I am thinking about removing my SKPaymentTransactionObserver the moment the app loses focus, and the adding it again when it next becomes active.
The weird thing about about this bug is that you get stuck with a transaction in the purchasing state, however when you properly shutdown the app and the restart it you would expect that transaction in the purchasing state to still be there, however it is not... As if the re-adding the SKPaymentTransactionObserver has triggered it to properly re-evaluate it's state.