问题
is there any event Listener that calls when we press on iPhone close button in phonegap?
so that we can do final task when application close.
i have found that onunload method will call when webpage redirect but it want work here.
please help me.
回答1:
Under the PhoneGapDelegate.m
class, you have the applicationDidEnterBackground
method, replacing from iOS 4+ the applicationWillTerminate
method for applications supporting background execution.
回答2:
You can listen to Phonegap's "pause" event:
document.addEventListener("pause", yourCallbackFunction, false);
http://docs.phonegap.com/en/2.9.0/cordova_events_events.md.html#pause
来源:https://stackoverflow.com/questions/18931722/exit-button-event-in-phonegap-for-ios