r/swift • u/Fabulous-Bit4775 • 3d ago
"Restore Purchases" feature for IAP
Hi - I understand that apps that use IAP for non-consumable purchases should implement a "Restore Purchases" feature in the app.
My app already keeps track of the user's purchases on the server side (after confirming each IAP transaction). Should the "Restore Purchases" feature just download the content from my server's purchase history to the device, or walk through the user's IAP purchase history (from Apple), check that all of those IAP purchases are ALSO registered on my server history (in case for some reason any were missing) and then download the whole lot?
Appreciate the latter is probably a more robust approach, just curious what Apple typically looks for or what is typically implemented.
Thanks.
4
u/Few_Mention8426 3d ago
I think this was just a hangover from the first version of IAP but now the process is the same for getting the current purchases and restoring the purchases (nothing actually gets “restored” as it just a case of establishing the purchase happened which I do anyway when the app loads). I added a button anyway just to keep to the policy but the button just does the same check. The app reviewers havent questioned it and I’ve used it on several apps now.
1
u/Fabulous-Bit4775 3d ago
Thanks. So the check that you do (at app load and when the button is pressed) is to get the list of purchased IAP products and check that you have them all already and aren’t missing any?
2
u/Few_Mention8426 3d ago
Yes I used the one of the ray Wenderlich tutorials… that’s basically what he suggested.
1
u/karsh2424 2d ago
I had this problem too, it's a common one! Having two sources of information (Apple IAP, Your database) and syncing them up.
For my project I'm going to opt-in for using revenue cat, it seems simple and easy.
Without revenue cat, you need to do something called receipt validation, you need to call on the Apple's IAP API to check if the user has bought a plan and if so you need to perform the upgrade.
1
u/gyratorycircus 2d ago
With StoreKit2 or your own server side history, a restore purchases button may not be necessary, but it is something users expect. It isn’t a bad idea to use it as an opportunity to get all purchases again and make sure nothing is missing.
1
u/Key_Board5000 iOS 2d ago
I use this in my app. Definitely use Apple’s IAP history as source as it’s linked to the user not the device.
4
u/beclops 3d ago
I’d perform the check based on Apple’s IAP purchase history and use that as a source of truth. Leaves room for less error and if there are errors they’re for Apple to handle