Automatic non-visual preservation of Navigation Stack in Ionic 2 app


#1

I have an app with a number of screens that make up the Sign Up process of the app. The user sees Screen 1, hits a Next button to see Screen 2 and so on. Each screen is pushed onto the stack allowing the user to go back to the previous screen if required.

I want the app to retain its navigation stack state if the app is killed i.e if the user has displayed Screen 1 and moved onto Screen 2 and then they kill the app and re-open it, I want Screen 2 displayed rather than Screen 1 (but also with a back button allowing them to get back to Screen 1).

The way I currently have this working is by saving the current screen number in LocalStorage when each screen is opened. And also pushing the next screen onto the navigation stack automatically if the LocalStorage value shows that the current screen was not the last screen opened. As each screen is opened it checks whether a later one was opened previously and if so, pushes the next screen onto the nav stack.

This works i.e if I open Screen 1 and then hit the Next button to go to Screen 2 and then I kill the app and re-open it, Screen 2 is displayed with a working back button. However, an obvious downside of this is that I see Screen 1 being displayed first before I see Screen 2.

Presumably there is a much better way of preserving the navigation stack and resuming it like this without the history of the navigation being visually repeated when the user re-opens the app after killing it ? I remember doing this natively in ObjectiveC with some built in state preservation methods - is there something similar in Angular / Ionic ?


#2

I am having a similar issue with the navigation stack in Ionic 2 as well. I used the tutorial demo with slider menu as my starting project. I am looking at using this as a mobile website in addition to building native apps. When the browser is refreshed, the app defaults back to the specified home page.

I can see how this probably isn’t an issue for mobile app. However, for a mobile web site, I can see this being a problem.