libgdx / gdx-pay

A libGDX cross-platform API for InApp purchasing.
Apache License 2.0
225 stars 82 forks source link

Purchase restoration on iOS #37

Closed mickmuzac closed 9 years ago

mickmuzac commented 9 years ago

As of now, I am not locally storing items that have been purchased. On Android, that isn't a problem because I'm able to call PurchaseSystem.purchaseRestore and build the array of unlocked id's at runtime every time the app is launched.

On iOS, restoring the purchases displays an ugly password prompt and will also get the app rejected if it's not done explicitly by the user. As such, should the app persist purchases locally? If so, I think a note should be added to the readme to reflect this.

Presumably, using libgdx's Preferences class for this shouldn't be much of a problem, right?

noblemaster commented 9 years ago

Yes, that's correct, you should ONLY call purchaseRestore() when a user requests it! It's fine for Google Play but as you said, it won't work cross-platform for all payment providers. You need to have a designated [Restore] button on iOS.

re-persistance: yes, I would recommend you persist all the purchases in Preferences or a file somewhere in your app's directory (up to you). We should probably add an Inventory.java to gdx-pay eventually that will take care of persistance and provide additional utility methods. Unfortunately I won't get to it anytime soon.

The information in regards to purchaseRestore() is already on the gdx-pay homepage:

(*) IMPORTANT: PurchaseSystem.restore() should not be called directly by your application. Restoring purchases shall only be called when a user explicitly requests it. In your application add a [Restore Purchases] button which in turn will call this method. This is a requirement by Apple iOS. If you don't provide a button for purchase restores your application will be rejected! You have been warned :)

mickmuzac commented 9 years ago

Thanks for your response. I'll go ahead and implement the persistence via Preferences. It should be very easy to do. If someone is willing to find a way to hack it, then so be it. I'm not too concerned about that.

The information in regards to purchaseRestore() is already on the gdx-pay homepage:

Yes, you are correct. What I was saying was that the readme doesn't explicitly tell users to persist data on iOS devices. It only implies that you have to persist the data because you can't poll their service when the app is started.

Whether or not that changes is up to you guys. But I like the idea of everything being 100% spelled out to help avoid confusion and questions like this one.

Great job on the library by the way!

noblemaster commented 9 years ago

I am not much of a writer - sorry for the confusion :)

aberkowski commented 6 years ago

I think that @mickmuzac is right. It should be some info that on iOS you should persist purchases yourself. I was sure that I do not have to remember user purchases on my hand.