Added 'resign' and 'active' events. I added two new events because applicationWillResignActive and applicationDidBecomeActive were not firing events the way applicationDidEnterBackground (pause) and applicationWillEnterForeground (resume) were. This was fine in the case of applicationWillEnterForeground (resume) but applicationDidEnterBackground (pause) was not able to get the event back to the JavaScript side before the app went into the background. See http://stackoverflow.com/questions/8223020/pause-event-is-not-working-pr operly-in-phonegap-iphone/8224125#comment10128466_8224125
This meant the event was essentially not firing until the app resumed again. The method applicationWillResignActive (resign) occurs earlier in the event chain so your PhoneGap app has a chance to turn off timers, etc. The only downside is that this event is also fired when the screen is locked even if your app is not truly in the background. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/e1c759f4 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/e1c759f4 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/e1c759f4 Branch: refs/heads/master Commit: e1c759f48af4d6fedeaab69d0c0988c868f639bd Parents: d5962f1 Author: tommy-carlos williams <to...@devgeeks.org> Authored: Fri Nov 25 18:36:39 2011 +1100 Committer: tommy-carlos williams <to...@devgeeks.org> Committed: Fri Nov 25 18:36:39 2011 +1100 ---------------------------------------------------------------------- PhoneGapLib/Classes/PhoneGapDelegate.m | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/e1c759f4/PhoneGapLib/Classes/PhoneGapDelegate.m ---------------------------------------------------------------------- diff --git a/PhoneGapLib/Classes/PhoneGapDelegate.m b/PhoneGapLib/Classes/PhoneGapDelegate.m index 02d2a18..06032bd 100644 --- a/PhoneGapLib/Classes/PhoneGapDelegate.m +++ b/PhoneGapLib/Classes/PhoneGapDelegate.m @@ -819,6 +819,7 @@ BOOL gSplashScreenShown = NO; - (void)applicationWillResignActive:(UIApplication *)application { //NSLog(@"%@",@"applicationWillResignActive"); + [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('resign');"]; } /* @@ -836,6 +837,7 @@ BOOL gSplashScreenShown = NO; - (void)applicationDidBecomeActive:(UIApplication *)application { //NSLog(@"%@",@"applicationDidBecomeActive"); + [self.webView stringByEvaluatingJavaScriptFromString:@"PhoneGap.fireDocumentEvent('active');"]; } /*