Reputation: 2960
How can I distiguish the condition when a user is hitting restore but has never bought that IAP package before.
When I trigger
SKPaymentQueue.default().restoreCompletedTransactions()
the system triggers the following callbacks
1) For an already-bought item those 2 in that order
func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction])
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
2) For an not-yet-bought item simply
func paymentQueueRestoreCompletedTransactionsFinished(_ queue: SKPaymentQueue) {
With this possible combinations, how can I ensure / verify that the call 'restore' was called, but the result is "not yet bought".
Do I really have to save the state "paymentQueue was not yet called and now paymentQueueRestoreCompletedTransactionsFinished was called" as condition?
Upvotes: 0
Views: 174
Reputation: 114826
All you need to do is process any purchases that are delivered to updatedTransactions
as you do for the initial purchase case. Ie. unlock content or provide additional functions and persist the purchase in keychain or whatever method you are using.
paymentQueueRestoreCompletedTransactionsFinished
lets you know that the restore operation is complete. You can use this method to update your UI if required. For example if you showed an activity indicator when you started restoring then you can use this callback to remove that indicator.
Upvotes: 1