Skip to main content
Solved

How to detect lifetime access when restoring purchase?


Forum|alt.badge.img+3

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

        }

    }

}

Best answer by JTostitos

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

View original
Did this post help you find an answer to your question?

2 replies

Forum|alt.badge.img+3
  • Author
  • Helper
  • 2 replies
  • August 14, 2022

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?


Forum|alt.badge.img+3
  • Author
  • Helper
  • 2 replies
  • Answer
  • August 15, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings