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.
Answer: A: Answer: A: It means that if you made an in-app purchase in that game but on another device you can restore those purchases with your apple ID log in credentials without having to pay again.
If you haven't received an in-app item you bought, try closing and restarting the app or game you're using. Tap Apps or Manage applications (depending on your device, this may be different). Tap the app you used to make your in-app purchase.
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.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With