Hi all,
I was trying to implement MobileIAP into my game, and I succeeded to a certain degree (the game is already published on AppStore and the IAP purchase and restore purchase is working), but once purchased (or restored), I had to store the information about the purchase to a local storage, because I failed to get the information on new app start from the appstore using Has product. I would appreciate your help with this - if someone has more experience with it, what do I do wrong, because I haven't found the answer anywhere yet.
The way I thought I should do it, and I even found a .c3p example file I believe from the developer of the MobileIAP plugin himself (very old file though), which had it the same, was this:
The product registration was successful, the price was set successfully, but the "Has product" function did not trigger true (even though I had the product, because the "Restore purchase" did trigger "Has product" successfully).
I found on some forum that there was a problem with Has product in a past, especially because it is false at first and only trigger true after an unpredictable delay, so a new function On product owned was introduced. So I also tried to add this to a loader layout:
Didn't work. It seems like both Has product and On product owned trigger only after I call Restore purchase first (even though I understood from the documentation that at least On product owned should also trigger "on startup when the product was previously purchased".
I also tried to wait up to 10 seconds before I go to the next layout to give it a time to trigger, but it didn't help. I also tried to include the On product owned function on the next layout after the loader, but it also did not help.
How do you guys do it? Does On product owned / Has product work for you without calling Restore purchase first?
I thought I should not call Restore purchase on every startup, as this might prompt user login screen (at least in testing when not logged in), but maybe that is the way to do it? I mean, all ios users are logged in all the time I guess, so it whould not bother anyone. I dont't know what Restore purchase do when offline though. My understanding was that Has product should work even offline (once purchased) as it gets the information from the local encrypted appstore storage. And Restore purchase button is there in case you re-install the game to a new device and want to get this information from online appstore server and then store it offline to the device. But maybe I understand it all wrong.
It is also possible that the Has product did not work on test environment only (although I was testing it in Xcode with both StoreKit and in Sandbox with connected device and also through TestFlight with external testing and nothing worked).
Regarding the Product ID, Appstore connect settings, development certificates, I had all setup - as I said, everything else was working, price was updating, and I released the app after (using local storage to remember the purchase) and it passed the apple review. But ofc there still might be some other problems causing the Has product to not work, and that's why I'm here :) Anyone has experience with this? Anyone has currently published iOS app with successfully implemented MobileIAP and be willing to share? Thank you so much.