DedrisFrameworkDedrisFramework

← Plugins  /  Local Notifications

🛎️

Local Notifications

cordova-plugin-local-notification
iOS Android

This popular community plugin schedules notifications that fire entirely on the device — no server or network required. Use it for reminders, alarms, timers and offline alerts, with full control over the title, text, timing and the action a tap should trigger.

Installation

terminal
cordova plugin add cordova-plugin-local-notification

API

The plugin is exposed as cordova.plugins.notification.local after deviceready:

MethodDescription
schedule(options, cb)Schedule one notification or an array of them.
requestPermission(cb)Ask the user for permission to post notifications.
on(event, cb)Listen for schedule, trigger, click, clear or cancel.
cancel(id, cb) / cancelAll(cb)Cancel a scheduled notification, or all of them.
getScheduled(cb)Return all currently scheduled notifications.

Common options

KeyDescription
idA unique number you use later to cancel or update it.
title / textThe heading and body shown in the notification.
triggerWhen to fire, e.g. { at: new Date(...) } or { in: 1, unit: 'hour' }.
soundCustom sound to play, or false for silent.
dataArbitrary payload returned to your click handler.

Usage example

Request permission, then schedule a reminder for 30 minutes from now:

www/js/app.js
document.addEventListener("deviceready", onReady, false);

function onReady() {
  var local = cordova.plugins.notification.local;

  local.requestPermission(function (granted) {
    if (!granted) return;

    local.schedule({
      id: 1,
      title: "Stand up!",
      text: "Time for a quick stretch.",
      trigger: { in: 30, unit: "minute" }
    });
  });

  local.on("click", function (notification) {
    console.log("Tapped: " + notification.title);
  });
}

Tips

📚 Source: the technical reference on this page is based on the cordova-plugin-local-notification project (Apache-2.0 / MIT), maintained by the open-source community and widely used through Ionic Native. Descriptions and examples have been rewritten in DedrisFramework's own words. This plugin is not part of the Apache Cordova core.
← Back to plugins Start a project