Restoring the App state after Pause

Hi!
I wonder about the way we could restore an Ionic 2 App state after it’s minimized (paused) and its cache wiped out by the SO, etc

Designing a solution, I would like to know if the implementation of the Angular 2 router would help in this regard. Any thoughts @mhartington? TIA

Let’s say, I would like to reopen the same page the user was when he closed the App. I imagine that the router may help if I store the last route and try to restore it directly, if not I would have to make my own processing.

So for this, you could save the current navigation stack on pause, and post it to local storage.

Then if the app gets wiped, you could check for the value in local storage, and use nav.insertPages to rebuild the stack.

Though… this is a bit of work, and to be honest, I think it might be best let the os just wipe it.

1 Like

Can you help with how to “save the current navigation stack”. My existing code (which is not working ) is:

  let navStack = [];
  for (let i = 0; i < self.nav.length(); i++) {
    let view = self.nav.getByIndex(i);
    navStack.push({
      page: view.component,
      params: view.data
    });
  }