Release of PhoneGap Local Notification Plugin!
We’re happy to announce the release of the new PhoneGap Local Notification plugin with support for iOS and Android!
The Local Notification plugin gives developers the ability to post notifications from their app that show up in the device’s notification area. The API for the local notification plugin follows the W3C Web Notifications specification.
Android
iOS
Local Notification Plugin Installation Instructions
After you have built your project, install the plugin in your project location:
$ phonegap plugin add phonegap-plugin-local-notification
(or)
$ cordova plugin add phonegap-plugin-local-notification
Quickstart Guide to Using the Local Notification Plugin
The plugin and complete documentation are available for download here in the PhoneGap Repo.
To show a new local notification add this code to your application’s JavaScript:
if (“Notification” in window) {
Notification.requestPermission(function (permission) {
// If the user accepts, let’s create a notification
if (permission === ‘granted’) {
var notification = new Notification(“My title”, {
tag: ‘message1’,
body: “My body”
});
notification.onshow = function() { console.log(‘show’); };
notification.onclose = function() { console.log(‘close’); };
notification.onclick = function() { console.log(‘click’); };
}
});
}
To close a local notification make this call in your application’s JavaScript:
notification.close();
Stay Tuned!
This is the first version of the API… More improvements are coming down the pipeline! We will be continue to add more functionality as we incorporate feedback!
Issues
iOS requires that you specify the body for the notification. Without a title and a body the notification will not be shown.
Contact Us
Your feedback is graciously accepted and appreciated!
Please submit your pull requests and issues here.