Author Topic: How to tell if a user has made any in-app purchases when restoring transactions  (Read 5028 times)


  • Administrator
  • *****
  • Posts: 719
    • View Profile
If you are selling non-consumable, auto-renewable subscriptions, or non-renewing subscription products, Apple requires that you provide a UI that allows the purchases to be restored. If you donít, your app will be rejected by Apple.

When the user selects to restore in-app purchases, you can determine if any purchases were restored by adopting the SKPaymentTransactionObserver protocol and implementing the paymentQueueRestoreCompletedTransactionsFinished method. This method is called after all transactions have been restored. Within this method, you can check the queue object's transactions.count property. It contains the number of transactions that have been restored. If it's zero, there were no transactions to be restored:

Code: [Select]
public func paymentQueueRestoreCompletedTransactionsFinished(queue: SKPaymentQueue!) {
        let purchasesMade = queue.transactions.count > 0

This allows you to display a more intelligent "There were no purchases to restore" alert in this scenario.

All the best!
Author of Learn to Code in Swift:
« Last Edit: June 22, 2015, 03:45:48 PM by kjmcneish »