Created
April 13, 2012 00:06
-
-
Save jsoma/2372039 to your computer and use it in GitHub Desktop.
LocalNotification Cordova callback fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When upgrading the LocalNotification plugin from PhoneGap to Cordova, you run | |
// into the error "Request for member 'webView' in something not a structure or union" | |
// from the LLVM GCC 4.2 compiler. | |
// | |
// The wonderful callback support is to blame! | |
// | |
// You just need to edit AppDelegate.m and replace all instances of this.webView | |
// with this.viewController.webView and you'll be good to go! | |
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification | |
{ | |
UIApplicationState state = [application applicationState]; | |
if (state == UIApplicationStateInactive) { | |
// WAS IN BG | |
NSLog(@"I was in the background"); | |
NSString *notCB = [notification.userInfo objectForKey:@"background"]; | |
NSString * jsCallBack = [NSString | |
stringWithFormat:@"%@", notCB]; | |
[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsCallBack]; | |
application.applicationIconBadgeNumber = 0; | |
} | |
else { | |
// WAS RUNNING | |
NSLog(@"I was currently active"); | |
NSString *notCB = [notification.userInfo objectForKey:@"forground"]; | |
NSString * jsCallBack = [NSString | |
stringWithFormat:@"%@", notCB]; | |
[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsCallBack]; | |
application.applicationIconBadgeNumber = 0; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment