we are in the process of upgrading our existing Ionic 1 app (released in play store) to Ionic 3. When we release this Ionic 3 app as an update to existing app, we do not want existing users to be prompted to login again. The existing Ionic 1 app uses window.localStorage to store user login details. we would like to read the existing data and use it in Ionic 3 app and make it smooth transition for the users.
Even though we give the same package name, ionic 3 app is unable to read ionic 1 app’s local storage. Any help is highly appreciated!
I want to say any app update will wipe out the local storage. So your upgrade is going to force the user to login again.
Additionally:
- localStorage offers such weak persistence guarantees that I’ve never seen a situation where it’s the best option. Ionic storage is generally the best starting point for most applications, but…
- “store user login details” requires a bit more attention here. If you’re storing things like JWTs that are only valid for your specific app, that’s fine, but do not store passwords on device. Even though they shouldn’t, users reuse passwords. You don’t want your app to be implicated in your users’ losing control of their social media or online banking accounts.
Thanks for your response!
But in Ionic 1, we have released many app updates and it never wiped out local storage. The end users get an alert to update the app and after they do, it will not ask for login again as it will read the user info stored in local storage during the first login attempt.
But now, we built the app with Ionic 3, on a new code base but re-using existing business logic & services and functionalities. In the config.xml, we use the same old package name and just increase the version number.
This new app will be released just like the regular app update, where users should not be asked to login again. Instead, it should read the user info (UserID, Email and some app related data) from local storage and go to home screen as usual.
Ok. Then I am wondering if in creating the new Ionic 3 app, did it switch to using a different webview? If so that would stomp out the data.
Why don’t upgrade to ionic4?
ionic 3 should no more version update.
Here is an interesting fact. Below are the steps.
-
Build and run Ionic 1 app --> Login --> store user info in LocalStorage (say for example windows.localStorage.MyAppData = { userID: 23, email: ‘user23@test.com’, role:
ADMIN
} -
Build and run Ionic 3 app using same package name but increased version number in config.xml. It again points to login screen --> store user info in LocalStorage (say for example window.localStorage.MyAppData = { userID: 45, email: 'user45@verify.com`, role: ‘NORMAL’ }
-
Again build and run Ionic 1 app with just increased Version number in config.xml. It is able to read its data from windows.localStorage.MyAppData and directly go to Home screen with this first user’s (userID 23) dashboard.
-
Now, build and run Ionic 3 app with just increased Version number in config.xml. It is able to read its data from windows.localStorage.MyAppData and directly go to Home screen with second user’s ( userID: 45) dashboard.
From this we can infer that each app stores the localStorage in different files / paths. So using the same package name in config.xml and trying to read from the same variable from localStorage (‘MyAppData’) is NOT useful. They both return different data respectively.