Cordova Plugin for Extra App Lifecycle Events, including Terminate and Destroy.
Based heavily on:
Similar plugins which may better meet one's requirements include:
cordova plugin add cordova-plugin-lifecycle-events-extra
alert() and any other interaction with the user. Ensure that
your handler is "headless".
In your JS event handler, you should strong consider wrapping your JS code in setTimeout. Otherwise, AJAX calls, for example, will not work.
Included Additional Lifecycle Events
- willterminate = (UIApplicationWillTerminateNotification)
- didlaunch = (UIApplicationDidFinishLaunchingNotification)[https://developer.apple.com/documentation/uikit/uiapplicationdidfinishlaunchingnotification?language=objc]
Only after the
deviceready event has fired, add these event listeners within the deviceready handler's function body:
Warning! iOS does not broadcast any event upon termination when the app is already in the background!
Just register a beforeunload event on the body: