Hy! I need to catch the exit app event in my phonegap application. Actually I want to trigger a looseLife() function if the player tries to cheat and exit the app with minimize and exit from task manager while he already started a new lvl. If he exit it correctly, by pressing the back button it works fine.
I tried onunload or onbeforeunload but these functions get called only if I close the app normally, without minimizing it and closing it from task manager.
The pause function also doesn't help me because it gets triggered also if the screen is locked or when the user switches to another app and than back again.
How to catch the event when the app is minimized and closed in the task manager?
I found window.onbeforeunload to work better for cleaning up resources. Possibly off topic but I think window.onbeforeunload wouldn't create any race condition type issues.