Skip to content

Instantly share code, notes, and snippets.

@alunny
alunny / appActive.m
Created July 26, 2010 23:50
appActive event for phonegap-iphone
// insert this into your AppDelegate.m file
// this will fire an "appActive" event on the webview every time the app is launched
// whether through fast-app switching or a cold launch
- (void)applicationDidBecomeActive:(UIApplication *)application {
// delay of 1ms ensures code will be executed in new stack trace
// that way, event listener can't block applicationDidBecomeActive
// and crash the app
NSString *fireActiveEvent = @"window.setTimeout(function() { \n"
"var appActive = document.createEvent('Events'); \n"