IOS - How to save purchase data in the app?

I plan to incorporate some of the purchase elements in the application, and I want to save the purchase information / data so that iTunes backs up this information when my customers synchronize. Apple's documentation states that this is possible, but does not really tell you how to do this.

Where / how to save the purchase history (say, NSString for each item) so that iTunes supports it on the next synchronization?

Finally, how would you suggest that I test this before doing it all live?

Thanks.

PS Right now I'm using NSUserDefaults to store this information.

+4
source share
2 answers

NSUserDefaults is suitable for storing these kinds of things, but you should also use the StoreKit “check purchased goods” feature - many applications that use in-app purchases have a button somewhere where they check the “acquired” state of available products and reuse them in the app , in case the user uninstalls and then reinstalls the application or installs it on another device.

You can test in-app purchases using the sandbox environment - iTunes Connect allows you to set up a test iTunes Store account that has free access to all applications in the applications.

+9
source

In fact, NSUserDefaults is under

 <Application_Home>/Library/Preferences 

And the Library directory will be copied to iTunes.

Another way to save your app purchase data (because it is very small) is to store it in a keychain. Because keychain is safe and will be reserved when the application is uninstalled. Therefore, when the user installs the application again, the user can instantly receive his purchase. Check out this link: Lock: Easily protect your app’s sensitive data.

+4
source

Source: https://habr.com/ru/post/1333577/


All Articles