Group Group Group Group Group Group Group Group Group

In-App Purchases · Restoring Purchases | raywenderlich.com

#1

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1304447-in-app-purchases/lessons/18
#2

When restoring purchases - it looked like that we assume that a person with a brand new device is going to use their old apple id, If that’s not the case - then whats the process of getting that persons prior purchases restored?

#3

Are you asking if a person tries to restore their purchases using a different apple id? As far as I know, that’s not possible. You’d need to contact apple support to transfer purchases from one account to another. Only then would the restore purchases work.

#4

yeah thats what I was getting at assuming in the video, the restore purchases piece assumed the same apple id. I figured that you would have to contact apple. Thanks for responding

#5

Sure thing - good luck and definitely let me know what they say.

#6

I am running the RazeFace project from the IAP Tutorial Get started. And in particular the restore button. My assumptions are : UserDefaults are saved locally on the device, correct ? restoreCompletedTransactions are read from App Store Connect, on the network, and are independent from the device but dependent from the user. Correct ? Now my story. I am running RazeFace on an iPhone. I previously bought the product. The screen displays a checkmark for the purchased product. It makes sense as the code checks the UserDefaults (local) and yes it has been purchased on that device. Pressing Restore, I get the product restored. Unfortunately this is not significant as the checkmark is already displayed, so hard to notice a difference here.
Now, I run RazeFace on an iPad where I didn’t purchase the product before. The screen displays a checkmark for the purchased product. It doesn’t make sense as the code checks the UserDefaults (local) and no it has not been purchased before on that device. That’s the first inconsistency. Pressing Restore, I don’t get any error or transaction. This is the second inconsistency because the reading of AppStoreConnect should have returned the same transaction as for the iPhone case.
Now running the app on the Simulator where the product has not been purchased before. It displays the product with a Buy which is correct because the local UserDefaults are empty on that device for that product. Again, pressing Restore, and again not getting any transaction back. Third inconsistency (but same as second one)
With these three situations, it looks to me that the transactions from AppStoreConnect (at least for the Sandbox environment) are tied to the device and not independent. Has anyone tested the app across devices ? Something is wrong here as far as I understand and I am confused by what is stored locally or not. Thanks for any assistance

#7

The sandbox is tied to the account, not the actual device. When you test your in app purchases, make sure that you are logged in to the correct account. I’m guessing you were probably logged into a production user account versus the sandbox account that you created in iTunes Connect.

Just an FYI - don’t use User Defaults to locally persist your purchases. This is something that can be easily hacked. Aim to use the keychain instead.

Thanks!
Brian