Get back to index after reopening the app

Hello,

I open first time the app, than going to another page, let’s say settings. If I exit the app (not closing it) than reopening the app, I am still on settings page.
How can I get back to index?
Framework7 5.7.12

Thanks

Can you define what you mean by exiting. What platform are you running your app on?

On android or iOS, exiting by tapping home button on phone, but the app is running in background.
So when I came back I want to “reset” everything and see the index page again

On iOS (and I imagine the same process is in use on Android) the app is classed as ‘sleeping’ when you return to the home screen. If you tap the icon again, it ‘resumes’ the app from the same place you left off.

The only exceptions are Cordova apps which sometimes have a maximum sleep time, and reset themselves after this time period.

On iOS, ‘exiting’ the app is to hard-close the app (open the app switcher and force-close the app).

It is expected behaviour by the user for your app to resume from where it left off. For example, they might be using your app and need to switch over to the Notes app to write something down, then return back to your app to continue what they were doing. It would be poor user experience for your app to restart itself while they were away.

1 Like

I know, but I really need to get back to that page. This is how it should work

Try experimenting with this plugin https://github.com/katzer/cordova-plugin-background-mode

1 Like

found this, works with android, need to check iOS

    document.addEventListener("pause", onPause, false);
    document.addEventListener("resume", onResume, false);

update with timer :slight_smile:

var startTime, endTime;

function onPause() {
    // Handle the pause event
    startTime = new Date();
}

function onResume() {
    // Handle the resume event
    endTime = new Date();
    var timeDiff = endTime - startTime; //in ms

    // strip the ms
    timeDiff /= 1000;

    // get seconds 
    var seconds = Math.round(timeDiff);
    if(seconds > 60){
        app.views.main.router.navigate('/');
    }
}
1 Like