Skip to content

A Cordova/PhoneGap 3.0.0+ plugin to create local notifications on Android & iOS.

Notifications You must be signed in to change notification settings

gsmedley/Phonegap-LocalNotification

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova/PhoneGap Local Notification Plugin

A Cordova/PhoneGap 3.0.0+ plugin to create local notifications on iOS and Android.

iOS version originally by Olivier Lesnicki. Android version originally by Drew Dahlman.

Changes

  • Rationalize iOS/Android parameters
  • Support notifification icon - Android
  • Tap Notifification to open app - Android
  • Add other repeat periods - Android

TO DO

  • Test ios changes

Installing the plugin

Install the core plugin files via the Command-line Interface:

$ phonegap plugin add https://github.com/gsmedley/Phonegap-LocalNotification.git

Using the plugin

Within the www/js/index.js file, or any other included js files, the following will trigger a local notification after 5 seconds:

localNotifier.addNotification({
    date            : new Date(new Date().getTime() + 5000),
    message         : "This is a local notification.",
    id              : '1'  , // reusing an id will replace an existing notification
    repeat          : "" ,  // minute, hour, day, week

    // android only
    ticker          : "Alarm Ticker",
    icon            : "small_notification_icon",  // resource name

    // ios only
    sound           : "horn.caf" , // name of sound file
    hasAction       : true,
    action          : 'View',
    badge           : 0 ,        
    background      : function(notificationId){  console.log( "addNotification background callback") },
    foreground      : function(notificationId){   console.log( "addNotification foreground callback")  }
});

To cancel a notification:

localNotifier.cancelNotification(1);

To cancel all notifications:

localNotifier.cancelAllNotifications();

Uninstalling the plugin

To uninstall the plugin and its components, use:

$ phonegap plugin remove localnotification

About

A Cordova/PhoneGap 3.0.0+ plugin to create local notifications on Android & iOS.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 77.0%
  • Objective-C 14.6%
  • JavaScript 8.4%