I am testing a non-consumable In-App purchase and I found a strange issue. Here is my scenario:
1. User buys the In-App.
2. The app sends the receipt(Bundle.main.appStoreReceiptURL) for validation to my server which sends it to the app store /verifyReceipt
3. Receipt verification is successful, the app unlocks required features.
4. User closes the app.
5. User opens the app.
6. The app gets the user receipt (Bundle.main.appStoreReceiptURL) and sends it for verification.
7. The transaction for the In App not found.
If however I refresh the receipt by using SKReceiptRefreshRequest and then send it for verification, the transaction is back again. And it is there until the user restarts the app. If he does, the transaction is lost again until I call SKReceiptRefreshRequest.
I am having this issue with local builds and builds downloaded using TestFlight.
I also noticed, that when the required transaction are not present in the receipt, there are other transactions which I did not make using the current user. Those other transaction are for an auto-renewable subscription which I also have in my app.
Also the issue is currently reproducing only on one of my device(iPhone 5s). On my other iPhone all seems to work fine.
It looks for me like the local receipt on my 5s iPhone has got corrupted or something and it does not persist the changes after the SKReceiptRefreshRequest.
Is there a way to completely remove the receipt for the sandbox environment so I could start from scratch?
Absolutely not.
You need to have a restore function for those few users who share a device with other users. Usually a device has only one user and the receipt will be the appropriate receipt. If the receipt is not the appropriate receipt then the user knows exactly why they must restore the IAP - and usually that is because they didn't buy the IAP from you but their friend did.