pause
The pause event fires when the native platform puts the application into the background, typically when the user switches to a different application.
Quick Example
document.addEventListener("pause", onPause, false); function onPause() { // Handle the pause event }
iOS Quirks
In the pause
handler, any calls to the Cordova API or to native plugins that go through Objective-C do not work, along with any interactive calls, such as alerts or console.log()
. They are only processed when the app resumes, on the next run loop.
The iOS-specific resign
event is available as an alternative to pause
, and detects when users enable the Lock button to lock the device with the app running in the foreground. If the app (and device) is enabled for multi-tasking, this is paired with a subsequent pause
event, but only under iOS 5. In effect, all locked apps in iOS 5 that have multi-tasking enabled are pushed to the background. For apps to remain running when locked under iOS 5, disable the app's multi-tasking by setting UIApplicationExitsOnSuspend to YES
. To run when locked on iOS 4, this setting does not matter.
Please login to continue.