So I have a client object I want to write to a file before the app is killed. Does anyone know if the browser beforeunload event works for that purpose? Or does Cordova have a native way to handle that condition?
I know there are the "pause" and "resume" events, but I'm not sure if those handle the "kill" event as well. I can't seem to find any documentation on this anywhere.
If anyone can point to the right direction of have a recommendation it would be appreciated.
After a little bit more digging and some trial and error, I guess the proper way to handle this is to listen to the "pause" event I mentioned in my question. It seems to fire every time the user even pulls up the menu to kill the app. It should work then for my purposes.
document.addEventListener("pause", function () {
app.inBackground = true;
app.saveData();
}, false);
I'm not sure if it follows any standard or there is a better way to do it, so if anyone else has more info, feel free to leave it here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With