简体   繁体   中英

Will NSUserDefaults Persist from TestFlight to the Final App Store Version?

I had my app installed on my phone using Xcode and when I installed it from TestFlight I got an alert saying that the app was already installed and asking of I wanted to replace it, to which I said yes.

The alert said the app's data could be lost, but actually it was all there, including data saved to nsuser defaults.

So my question is, would the same happen when installing the final version downloaded from the app store on top of the TestFlight version?

I'm asking this because my app has an in app purchase and what the purchase does is set a bool to true and persist it to nsuserdefaults. I want my beta testers to get the in app purchase for free, so I'm wondering if that bool will still be set to true when they get the final version.

If the app from App Store has the same Bundle ID as the app from TestFlight, then NSUserDefaults won't be erased ( I assume that when you download the App from App Store, the app from TestFlight is installed on your iOS device ).

And yes, handling in-apps in NSUserDefaults is not a good solution. You can take a look in something like MKStoreKit to handle in-apps.

This seems to be a typical XY question: You ask about one thing (user defaults) but you really want to solve a different problem (in-app purchases).

When you do in-app purchases, your app needs to have a way to restore purchases, so that anyone buying a new iOS device can download the app that they bought, and restore all the purchases.

In that case there will be no user defaults because it is a brand new phone or iPad.

And people using TestFlight should be aware that they are beta testers and all kinds of unpleasant things could happen, including crashes, destruction of data, loss of in-app purchases and so on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM