gpt4 book ai didi

ios - 在应用程序购买观察者中恢复调用 addPayment 而不是恢复

转载 作者:行者123 更新时间:2023-11-30 14:07:27 25 4
gpt4 key购买 nike

在另一台设备上恢复应用内购买时,恢复调用“购买”而不是“恢复”

  • 按钮已正确连接

  • 如果之前已按下购买操作(即使已取消),即使应用程序已进入后台,此操作也可以解决问题。

  • 仅在其他设备上恢复购买时显示

  • 自动续订订阅

已按下购买

SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().addPayment(pay as SKPayment)

商店套件

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
println("Purchasing")

恢复按下

SKPaymentQueue.defaultQueue().addTransactionObserver(self)
SKPaymentQueue.defaultQueue().restoreCompletedTransactions()

Storekit 应该调用

func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
println("transactions restored")

实际通话(如果之前未进行过购买,则在另一台设备上)

func paymentQueue(queue: SKPaymentQueue!, updatedTransactions transactions: [AnyObject]!) {
println("Purchasing")

更新

添加

dispatch_after(dispatchTime, dispatch_get_main_queue(), {

SKPaymentQueue.defaultQueue().addTransactionObserver(self)

})

SKPaymentQueue.defaultQueue().restoreCompletedTransactions()

按“恢复”按钮可以修复大多数情况,可以使用更永久的解决方案

最佳答案

您应该尽快设置事务观察器(当调用 application:didFinishLaunchingWithOptions: 时),而不是在处理恢复按钮点击时。根据documentation :

Your application should add an observer to the payment queue during application initialization. If there are no observers attached to the queue, the payment queue does not synchronize its list of pending transactions with the Apple App Store, because there is no observer to respond to updated transactions.

关于ios - 在应用程序购买观察者中恢复调用 addPayment 而不是恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32186201/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com