Application recovery in the application

I try to shop in the app and everything works fine except Restore. Below is the code I wrote:

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 I am encountering here is that I am not getting the purchased identifier here. I think I messed up the code.

+6
source share
2 answers

Add below two lines of code to the click action button

 SKPaymentQueue.default().restoreCompletedTransactions() SKPaymentQueue.defaultQueue().addTransactionObserver(self) 

Edit - for Swift 3:

 SKPaymentQueue.default().add(self) SKPaymentQueue.default().restoreCompletedTransactions() 
+1
source

Riyazul, you need to see the initial transaction when you restore purchases.

The code you need is:

 var identifier : NSString = trans.originalTransaction.payment.productIdentifier 

Let me know if it still does not work.

0
source

Source: https://habr.com/ru/post/978011/


All Articles