Skip to content

05. Update

Sebastián Katzer edited this page Mar 5, 2015 · 2 revisions

Scheduled local notifications can be updated before they get presented to the user. Its also possible to update them if yet triggered and added to the notification center.

Semantic

Update local notifications is similar to cancel and re-schedule them. With the difference that there will be no cancel event for the old local notification and the plugin corrects the repeat interval if necessary.

Interface

The update() interface takes a hash as an argument to specify the local notification's properties or an array of hashes. and optionally a callback function and a scope as second and third argument. The default scope does point to the plugin.

The following list gives an overview about all properties that can be changed. Only provided local notifications are changed. Each local notification requires a numerical ID, that cannot be changed!

  • title
  • text
  • every
  • at, firstAt
  • sound
  • data

Android provides some additional properties as listet below.

  • icon
  • smallIcon
  • ongoing
  • led

Update Single

cordova.plugins.notification.local.update({
    id: 1,
    text: "Updated Notification",
    data: { updated:true }
});

Update Multiple

cordova.plugins.notification.local.update([{
    id: 1,
    title: "Updated Notification 1"
},{
    id: 2,
    title: "Updated Notification 2"
}]);

Events

The update event is fired for each local notification when calling update().

cordova.plugins.notification.local.on("update", function(notification) {
    alert("updated: " + notification.id);
});
Clone this wiki locally