Prevent Ionic 2 App from "reloading" after app inactivity

Is it possible to prevent an Ionic 2 app from “reloading” after the app has been inactive (i.e. paused / minimized) for an extended period of time (e.g. 2hrs +)

I have a screen on my app where a user can enter data during an experiment. This experiment can take several hours to record the required data, so there may be long periods of inactivity where the user does not use the app and may let their phone go to sleep and/or “minimize” (i.e. not close) the app and run other apps. The problem I am facing is that if a couple of hours go by and the user “maximizes” the app again (i.e. selects it again to bring it to the foreground) then the app will have a tendency to “reload” itself, I.e. splash screen and home page a re-displayed, etc. This results in the loss of any of the data entered on the data entry screen with no ability to recover it (as it was never “saved”)

Is there any way to guarantee that when the user “maximizes” the app again that it doesn’t reload itself and stays on the data entry screen?

This should be it. I’m even gonna do that myself now!

BackgroundMode.setDefaults({
	silent: true
}).then(() => {
	BackgroundMode.enable();
}, () => {});

Edit: Changed .configure() to .setDefaults(), because .configure() is for changing the notification which is already displayed.

1 Like

Great, I will give this a go too. Is it applied on a page-by-page basis?

Please let me know how you get on!

Nope just put it in the App Component, though you could make it a page-by-page thing if you wanted, just enable/disable when loading other components.