Hi. I’m trying to set up probably the simplest instance of In App Purchases (IOS) but am having some difficulties.
All I want to be able to do, is set up an IAP which once purchased would set a bool flag, and that is all. I want to use the flag to run the additional code for the additional features. Then of course be able to retrieve the confirmation that the purchase had been made on startup.
I’ve tried following the IAP demo but it’s more complicated than I need and I’m unsure what the essential parts are for my situation.
I imagine calling InAppPurchases::getInstance()->purchaseProduct (“myUpgrade”) would be the way to make the purchase initially, where I could then set flag after purchase completes. If this is correct, what do I need to do (in constructor) to recall the confirmation that this purchase has been made, so I can set the flag from here non startup?
There isn’t any info available relating to IAP apart from the demo, so any further pointers would be greatly appreciated.
I’m in the same situation – I need to persist a purchase locally on iOS, but it is not automatically restored by the Juce InAppPurchases class. As far as I understood the Tutorial implementation, the necessary steps for unlocking a product feature using In-App Purchase (IAP) are:
- Configure the IAP in app store connect
- On app startup, fetch product and localized pricing information using
- Product information is returned in
InAppPurchases::Listener::productsInfoReturned(), but there is no information if the product has been bought already
- We can request a purchase of the product using
- Purchase success is returned in
InAppPurchases::Listener::productPurchaseFinished(). Now the feature can be unlocked locally, but this information is gone after the app is restarted
- We can request to restore completed purchases using
InAppPurchases::restoreProductsBoughtList(includeDownloadInfo) and retrieving the info in
InAppPurchases::Listener::purchasesListRestored(). But from my understanding, this step should be triggered manually and is only necesssary if the app was reinstalled or the user changed her/his device.
The original StoreKit framework documentation reads pretty similar and I cannot find any information on how to persist a purchase locally without calling restore. Of course we could simply store a enabled.disabled flag locally, but we would need to secure this setting against modification, and that’s exactly what I would expect from an IAP framework, right?
I wonder if the key would be to access the receipt that is returned by the App Store in step 5, and validate the receipt locally when the app is started. See Persisting a Purchase and Choosing a Receipt Validation Technique in Apple Developer Documentation. Something similar seems to be possible in Android using a purchaseToken in
Can someone help us here?
Hi Sebastian, I think you are having more luck than me!
Can I ask are you using Sandbox to do your testing?
FYI, I saw in JUCE 6.1.5 Release Notes:
- Updated the iOS in-app purchases workflow
The receipt handling has been changed slightly: iOS InAppPurchases: Use recommended receipt verification procedure · juce-framework/JUCE@2073e46 · GitHub
As far as I understand, Sandbox is automatically active when testing in Debug mode.