I want to implement annual subscription into my app, and I do it using StoreKit
. The problem is, when I tap subscriptionButton
. An app throwing an error: 'NSInvalidArgumentException', reason: 'Cannot finish a purchasing transaction'
. I was stuck in this place and can't resolve my problem. So, my paymentQueue
code looks like that:
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)
}
}
Do you have any suggestion, how can I fix it?
Working solution of this problem in my case is: