I'm developing my first FirefoxOS app and I need it to backup some data when the user closes or pauses the app. How can I detect this?
I've tried "window.onunload" but it doesn't seem to work.
Thank you.
You should be able to use page visibility API for background switch.
document.addEventListener("visibilitychange", function () {
if (document.hidden) {
console.log("App is hidden");
} else {
console.log("App has focus");
} });