我想在我的应用程序中实现年度订阅,我使用StoreKit
. 问题是,当我点击subscriptionButton
. 一个应用程序抛出错误:'NSInvalidArgumentException', reason: 'Cannot finish a purchasing transaction'
. 我被困在这个地方,无法解决我的问题。因此,我的paymentQueue
代码如下所示:
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) {
print(transactions)
for transaction in transactions {
print(transaction.error ?? "")
switch transaction.transactionState {
case .deferred:
print("deffered")
case let .failed(err):
print("failed: \(err)")
case .purchased:
let productID = p.productIdentifier
selectProduct(productID: productID)
case .purchasing:
print("purhasing")
print("produkt name: \(p.localizedTitle)") // after executing this line of code app crashes
case .restored:
let productID = p.productIdentifier
selectProduct(productID: productID)
}
queue.finishTransaction(transaction)
}
}
你有什么建议,我该如何解决?