#PhoneGap 3.x Local Notifications
Supported Platforms:
- Android
- iOS
##Setup - iOS
-
In
CordovaLib/Classes/CDVPlugin.m
uncomment the following line ininitWithWebView
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveLocalNotification:) name:CDVLocalNotification object:nil];
-
In
CordovaLib/Classes/CDVPlugin.m
uncomment the following block at the end of the file- (void)didReceiveLocalNotification:(NSNotification *)notification {}
-
In
CordovaLib/Classes/CDVPlugin.h
uncomment the following line- (void)didReceiveLocalNotification:(NSNotification *)notification;
-
In
Classes/AppDelegate.m
add the following to thedidFinishLaunchingWithOptions:
delegateUILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (notification) { [[self.viewController settings] setValue:notification forKey:@"LaunchOptionsLocalNotificationKey"]; }
-
In
Classes/MainViewController.m
add the following to thewebViewDidFinishLoad:
delegateUILocalNotification *notification = [[self settings] objectForKey:@"LaunchOptionsLocalNotificationKey"]; if(notification) { [[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification]; }