Whats the best way to listen for when my Ionic 3 application is closed?
I can set window.onbeforeunload and its fired when the app is terminated in the browser and on android devices but doesn’t get executed on iOS. I’ve also tried window.onpagehide. Still no dice. Any other ideas?
Some kind of app terminated event seems like it would be available through the ionic platform api right along with deviceready and pause/resume events.
I use this, inside the platform.ready in app component
platform.pause.subscribe(() => {
//inside the app
//what you need to do
});
platform.resume.subscribe(() => {
//outside the app
//what you need to do
});
1 Like
Hi
platform.pause.subscribe(() => {
//inside the app
//what you need to do
localStorage.setItem(“date”,new Date().toString());
});
is called when i am killing the app.
But i am not able to set a localStorage.
I think it is safer to assume that you cannot be reliably notified when your app is about to exit, and plan accordingly.