Hi All,
I would like to clear all the previous data stored except the user token whenever the App is updated. So every new App release will start fresh as if it was just installed.
Any suggestions how to achieve this?
tks
I am interested in knowing about this too. Is there any example of updating data and purging existing one effectively?
Here's how I handle it:
1. I construct an "app version string" from data found in Info.plist: specifically, the "marketing version" and the build number. A version string looks like this: v2.19b311. These values are managed by Xcode command-line tools, which execute as part of my production-build script:
- xcrun agvtool new-marketing-version 2.19 sets what we might call the major and minor version numbers
- xcrun agvtool next-version -all increments the build number
1. I expose the version string to the application as a prop of the root component. This requires changes to the obj-c in AppDelegate.m; the relevant properties from Info.plist are: CFBundleShortVersionString (major + minor) & CFBundleVersion (build number).
2. The app saves the appVersionString to the redux store; if it notices that the value has changed, it resets the store to the (current) default state as part of the save operation.
WARNING: sometimes this prop comes through as an empty string, so the check cannot simply be this.props.appVersionString !== store.appVersionString -- that would cause the app to wipe the store when the component lifecycle experiences a hiccup. Instead, you must check for a non-empty value that differs from the current value.
I am handling this scenario with https://github.com/wildlifela/redux-persist-migrate
redux-persist-migrate requires manually specifying migration functions. If you want to do it automatically you @tomprogers has a great suggestion.
Most helpful comment
Here's how I handle it:
1. I construct an "app version string" from data found in Info.plist: specifically, the "marketing version" and the build number. A version string looks like this:
v2.19b311. These values are managed by Xcode command-line tools, which execute as part of my production-build script:-
xcrun agvtool new-marketing-version 2.19sets what we might call the major and minor version numbers-
xcrun agvtool next-version -allincrements the build number1. I expose the version string to the application as a prop of the root component. This requires changes to the obj-c in AppDelegate.m; the relevant properties from Info.plist are:
CFBundleShortVersionString(major + minor) &CFBundleVersion(build number).2. The app saves the
appVersionStringto the redux store; if it notices that the value has changed, it resets the store to the (current) default state as part of the save operation.WARNING: sometimes this prop comes through as an empty string, so the check cannot simply be
this.props.appVersionString !== store.appVersionString-- that would cause the app to wipe the store when the component lifecycle experiences a hiccup. Instead, you must check for a non-empty value that differs from the current value.