gpt4 book ai didi

swift - SKPaymentQueue 未完成自动续订订阅产品的 SKPaymentTransaction

转载 作者:搜寻专家 更新时间:2023-10-31 08:08:06 26 4
gpt4 key购买 nike

我正在尝试实现自动续订产品。问题是 SKPaymentQueue 无法通过调用 SKPaymentQueue.defaultQueue().finishTransaction(transaction) 完成 SKPaymentTransaction

func paymentQueue(queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
if let transactions = transactions as? [SKPaymentTransaction] {
for transaction in transactions {
switch transaction.transactionState {
case .Purchasing:
break
case .Purchased:
queue.finishTransaction(transaction) // finish transaction
self.purchasedWithTranasction(transaction)
case .Failed:
queue.finishTransaction(transaction) // finish transaction
self.failedWithTransaction(transaction)
case .Restored:
queue.finishTransaction(transaction) // finish transaction
self.restoredWithTransaction(transaction)
case .Deferred:
queue.finishTransaction(transaction) // finish transaction
}
}
}
}

如上,在paymentQueue:updatedTransactions:方法中,调用了queue.finishTransaction(transaction)。一般情况下,交易结束,不会再停留。

但是当我再次运行该应用程序时,交易仍未完成。顺便说一下,我在 AppDelegate 中设置了事务观察器,如下所示。因此,当应用程序启动时,剩余的交易开始通过调用 paymentQueue:updatedTransactions: 进行处理。这和我的预期不一样。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// add transaction observer
SKPaymentQueue.defaultQueue().addTransactionObserver(CargoBay.sharedManager())

....

return true
}

你们对这个问题有什么想法吗?是否存在 SKPaymentQueue.defaultQueue().finishTransaction(transaction) 未完成交易的情况?

最佳答案

是否有可能您没有再次看到相同的交易,而是来自 iTunes 沙盒的新自动续订交易?

在 iTunes 沙盒中测试自动续订订阅时,他们人为地加快了续订速度。这会导致每隔几分钟出现一个新事务。

来自 Testing Your App and In-App Purchase Products :

When testing auto-renewable subscriptions in the test environment, keep in mind that the duration times are compressed. Additionally, test subscriptions only auto-renew a maximum of six times.

  • 1 week : 3 minutes
  • 1 month : 5 minutes
  • 2 months : 10 minutes
  • 3 months : 15 minutes
  • 6 months : 30 minutes
  • 1 year : 1 hour

关于swift - SKPaymentQueue 未完成自动续订订阅产品的 SKPaymentTransaction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38828163/

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