Reputation: 496
I'm trying to do in-app purchases and everything works fine except Restore. Below is the code I have written:
func paymentQueueRestoreCompletedTransactionsFinished(queue:SKPaymentQueue!)
{
for transaction:AnyObject in queue.transactions
{
let trans : SKPaymentTransaction = transaction as SKPaymentTransaction
var identifier : NSString = trans.payment.productIdentifier
println(identifier)
}
}
The problem that I face here is I'm not getting the purchased identifier
here. I think I have miswritten the code.
Upvotes: 6
Views: 1128
Reputation: 11
Add below two lines of code on your button click action
SKPaymentQueue.default().restoreCompletedTransactions()
SKPaymentQueue.defaultQueue().addTransactionObserver(self)
Edit - for Swift 3:
SKPaymentQueue.default().add(self)
SKPaymentQueue.default().restoreCompletedTransactions()
Upvotes: 1
Reputation: 23
Riyazul, you need to look at the original transaction when you are restoring purchases.
The code you should need is:
var identifier : NSString = trans.originalTransaction.payment.productIdentifier
Let me know if it's still not working.
Upvotes: 1