Search code examples
iosswiftstorekit

In App Purchase restore Not Working - iOS Swift StoreKit


I am using SwiftyStoreKit to handle my in app purchasing. I have one non-consumable in-app purchase. I am unable to restore the purchase. I am testing this on a release version of my app where I have been charged before for it, but it will not restore. The code I am using to call SwiftyStoreKit is as follows:

SwiftyStoreKit.restorePurchases(atomically: true) { results in
    if results.restoreFailedProducts.count > 0 {
        print("Restore Failed: \(results.restoreFailedProducts)")
    }
    else if results.restoredProducts.count > 0 {
        print("Restore Success: \(results.restoredProducts)")
        self.defaults?.set(true, forKey: "UnlockApp")
        NotificationCenter.default.post(name: Notification.Name(rawValue: "transition"), object: nil)
        self.dismissView()
    } else {
        print("Nothing to Restore")
    }
} 

As you can see I set a user default in order to unlock features in the app, but this never triggers it always comes back with "Nothing to Restore"

Has anyone dealt with this, or know a possible reason for this behavior?

Edit: This is on a physical device, on a release version (not sandboxed purchase)


Solution

  • The solution was when i have a developer version on the phone, i must:

    1. Uninstall the developer version
    2. Restart iPhone
    3. Download production version from app store

    Then the restore purchase option will work