Solved

How to detect lifetime access when restoring purchase?

  • 14 August 2022
  • 2 replies
  • 126 views

Badge +2

When I tried to restore a lifetime access IAP on iOS with this code it did not detect a purchase. It seems to only work with subscriptions. Am I doing something wrong, or is there a different method to detect if a user has purchased a lifetime access IAP? Tried looking through docs but didn’t come across anything. Thanks for any help in advance.

Purchases.shared.restorePurchases { (customerInfo, error) in

    //Check customerInfo to see if entitlement is active

    attemptingRestorePurchase = true // Bool that starts loading indicator

    if customerInfo?.entitlements.all[Constants.entitlementID]?.isActive == true {

        paidCustomer = true //Mark user as paid

        attemptingRestorePurchase = false //stop loading indicator

    } else {

        if networkMonitor.isConnected { // Alert toggle - checks internet connection

            attemptingRestorePurchase = false // stop loading indicator

            restorePurchaseError.toggle() // Alert toggle - Restore not successful

        } else {

            attemptingRestorePurchase = false // stop loading indicator

            noInternetAlert.toggle() // Alert toggle - No internet connection

        }

    }

}

icon

Best answer by JTostitos 15 August 2022, 17:03

View original

2 replies

Badge +2

Update: Restoring an IAP on one device works but if I go to restore the purchase on a second device, it does not work. Anyone know why this happens?

Badge +2

Something was wrong with my code. Used the sample code from RevenueCat and it worked fine.

Reply