Local Notifications

Improve this doc

$ ionic plugin add de.appplant.cordova.plugin.local-notification

Repo: https://github.com/katzer/cordova-plugin-local-notifications

This plugin allows you to display local notifications on the device

Usage

import {LocalNotifications} from 'ionic-native';



// Schedule a single notification
LocalNotifications.schedule({
  id: 1,
  text: "Single Notification",
  sound: isAndroid? 'file://sound.mp3' : 'file://beep.caf'
  data: { secret: key }
});


// Schedule multiple notifications
LocalNotifications.schedule([{
   id: 1,
   text: "Multi Notification 1",
   sound: isAndroid ? 'file://sound.mp3' : 'file://beep.caf',
   data: { secret:key }
  },{
   id: 2,
   title: "Local Notification Example",
   text: "Multi Notification 2",
   icon: "http://example.com/icon.png"
}]);


// Schedule delayed notification
LocalNotifications.schedule({
   text: "Delayed Notification",
   at: new Date(new Date().getTime() + 3600),
   led: "FF0000",
   sound: null
});

Static Methods

schedule(options)

Schedules a single or multiple notifications

Param Type Details
options

update(options)

Updates a previously scheduled notification. Must include the id in the options parameter.

Param Type Details
options

clear(notificationId)

Clears single or multiple notifications

Param Type Details
notificationId

A single notification id, or an array of notification ids.

clearAll()

Clears all notifications

cancel(notificationId)

Cancels single or multiple notifications

Param Type Details
notificationId

A single notification id, or an array of notification ids.

cancelAll()

Cancels all notifications

isPresent(notificationId)

Checks presence of a notification

Param Type Details
notificationId

isScheduled(notificationId)

Checks is a notification is scheduled

Param Type Details
notificationId

isTriggered(notificationId)

Checks if a notification is triggered

Param Type Details
notificationId

getAllIds()

Get all the notification ids

getTriggeredIds()

Get the ids of triggered notifications

getScheduledIds()

Get the ids of scheduled notifications

get(notificationId)

Get a notification object

Param Type Details
notificationId

The id of the notification to get

getScheduled(notificationId)

Get a scheduled notification object

Param Type Details
notificationId

The id of the notification to get

getTriggered(notificationId)

Get a triggered notification object

Param Type Details
notificationId

The id of the notification to get

getAll()

Get all notification objects

getAllScheduled()

Get all scheduled notification objects

getAllTriggered()

Get all triggered notification objects

on(eventName, callback)

Sets a callback for a specific event

Param Type Details
eventName

The name of the event. Available events: schedule, trigger, click, update, clear, clearall, cancel, cancelall

callback

Call back function. All events return notification and state parameter. clear and clearall return state parameter only.

API

Native

General