LocalNotification

Local notification for time-based alerts.
GotCakes0.1.01
platforms: ios
$ cordova plugin add com.localnotification.gotcakes

Cordova/PhoneGap Local Notification Plugin

A Cordova/PhoneGap 3.0.0+ plugin to create local notifications on iOS, originally by Olivier Lesnicki. This may be used to schedule notifications or other functions that trigger at some point in the future.

Forked from hiattp so as to make changes sufficient to pass PGB submittal.

Installing the plugin

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

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

Place any .caf audio files into the Resources folder in Xcode. The horn.caf file has been included in this repo as an example. Note that the sound only plays if the notification is triggered while the app is in the background.

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({
    fireDate        : Math.round(new Date().getTime()/1000 + 5),
    alertBody       : "This is a new local notification.",
    repeatInterval  : "daily",
    soundName       : "horn.caf",
    badge           : 0,
    notificationId  : 123,
    foreground      : function(notificationId){ 
        alert("Hello World! This alert was triggered by notification " + notificationId); 
    },
    background  : function(notificationId){
        alert("Hello World! This alert was triggered by notification " + notificationId);
    }           
});