iosin-app-purchasestorekitreceipt-validation

Does refreshReceipt ask for AppStore credentials?


I have been testing In App Purchases for iOS in a sample app. I need to figure out if I can call refreshReceipt API immediately at the launch to check user's eligibility for some trial period subscriptions etc.

I have called refreshReceipt in AppDelegate's application:didFinishLaunching:options method but it asks me for AppStore credentials, basically the Sandbox user's password. I was not expecting this behaviour as read from Apple docs. Is it something that is happening because of the sandbox environment or does it happen in Production environment as well.

Also, does Restore Purchase trigger the AppStore login alert. Apple docs say it does, but recently I saw one of the music apps on my phone did not ask for credentials when I opted the option. It may be that they are not calling the StoreKit's restorePurchase API, rather using their own mechanism.


Solution

  • You'll receive the login prompt whenever the receipt isn't present on the device. In sandbox, there are no installation receipts so you're always seeing the popup. You should also notice that the receipt still doesn't exist after it's refreshed in sandbox unless you made a purchase.

    If the user is logged in to their iTunes account, a receipt should always be there in production.

    For restores, I would assume it follows this same logic (asks for prompt if receipt isn't present) but this contradicts what Apple says.