Search code examples
iosnsuserdefaultstestflight

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.


Solution

  • 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.