Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS -- How to save in-app purchase data?

I'm planning on implementing some in-app purchase items and I want to save purchase information/data such that iTunes will backup said information when my customers sync. The Apple provided documentation states that this is possible, but doesn't really tell you how.

Where/how do I save purchase history (let's say, a NSString for each item) such that iTunes will back it up on the next sync?

Lastly, how would you suggest that I test this before making all of this go live?

Thanks.

P.S. Right now I'm using NSUserDefaults to store this info.

like image 929
RyanM Avatar asked Dec 28 '10 14:12

RyanM


People also ask

Are in-app purchases saved?

In-app purchases that aren't consumable can be restored. If you reinstall an app, reset your Android device, or get a new Android device, you can regain access to those in-app purchases. To do this, ensure you sign into Google Play with the same Google account you used to buy them.


2 Answers

NSUserDefaults is fine for storing that kind of thing, but you should also use StoreKit's “check for purchased items” capability—a lot of apps that use in-app purchases have a button somewhere that checks the “purchased” state of the available products and re-enables them in the app, in case a user uninstalls and then reinstalls the app or installs it on a different device.

Testing in-app purchases can be done using the sandbox environment—iTunes Connect will let you set up a test iTunes Store account which has free access to all of your app's in-app purchases.

like image 128
Noah Witherspoon Avatar answered Sep 17 '22 22:09

Noah Witherspoon


Actually NSUserDefaults is under

<Application_Home>/Library/Preferences

And the Library directory will be backed up by the iTunes.

Another way to save your in app purchase data (because it's very little) is to save it to keychain. Because keychain is safe and will be reserved when the app is deleted. So when user install the app again user can get their purchase instantly. Check this link:Lockbox: Easily Secure Your App’s Sensitive Data

like image 37
sunkehappy Avatar answered Sep 17 '22 22:09

sunkehappy