This plugin hooks into the Local Notification API, allowing you to create & cancel notifications for users of your app.
The goals of this project are to unify iOS & Android implementations and support the Cordova Plugin spec, so that it works with Pluginstall.
Great post explaining how to use pluginstall.
- Install via pluginstall
- Include LocalNotification.js in index.html
- Ensure R.java contains a 'drawable' 'icon', since we use it here:
int icon = res.getIdentifier("icon", "drawable", context.getPackageName());
- Start using window.plugins.localnotification
- Install via pluginstall
- Include LocalNotification.js in index.html
- Add the following code to AppDelegate.m
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
UIApplicationState state = [application applicationState];
if (state == UIApplicationStateActive) {
// WAS RUNNING
NSLog(@"I was currently active");
NSString *notCB = [notification.userInfo objectForKey:@"foreground"];
NSString *notID = [notification.userInfo objectForKey:@"notificationId"];
NSString * jsCallBack = [NSString
stringWithFormat:@"%@(%@)", notCB,notID];
[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
application.applicationIconBadgeNumber = 0;
}
else {
// WAS IN BG
NSLog(@"I was in the background");
NSString *notCB = [notification.userInfo objectForKey:@"background"];
NSString *notID = [notification.userInfo objectForKey:@"notificationId"];
NSString * jsCallBack = [NSString
stringWithFormat:@"%@(%@)", notCB,notID];
[self.viewController.webView stringByEvaluatingJavaScriptFromString:jsCallBack];
application.applicationIconBadgeNumber = 0;
}
}
- Start using window.plugins.localnotification
Originally forked from https://github.com/phonegap/phonegap-plugins
Repo format based on http://shazronatadobe.wordpress.com/2012/11/07/cordova-plugins-put-them-in-your-own-repo-2/
All the hard work on these plugins was done by Drew & Daniel.
I've merely collected them here and attempted to unify them.