Skip to main content

@napacitor/local-notification

Local Notifications plugin (the Napacitor counterpart of @capacitor/local-notifications): send immediate or scheduled system notifications, with permission requests, cancellation and tap callbacks.

Installation​

To use npm:

npm install @napacitor/local-notification

To use yarn:

yarn add @napacitor/local-notification

Sync native files:

npx nap sync

Usage​

import { LocalNotification } from '@napacitor/local-notification';

// Request notification permission (shows a system dialog on Android 13+ / iOS / Mac Catalyst)
const status = await LocalNotification.requestPermission();
// { granted: true }

// Send immediately
const result = await LocalNotification.schedule({
notifications: [{ title: 'Reminder', body: 'Time to drink water', id: 1 }],
});
// { notifications: [{ id: 1 }] }

// Send at a scheduled time (ISO 8601)
await LocalNotification.schedule({
notifications: [{ title: 'Meeting', body: 'Meeting at 15:00', id: 2, at: '2026-11-03T15:00:00Z' }],
});

// Cancel
await LocalNotification.cancel({ notifications: [{ id: 1 }] });

// Notification tap callback
const handle = await LocalNotification.addListener('notificationReceived', (payload) => {
console.log(payload.id, payload.title, payload.body);
});

await handle.remove();
await LocalNotification.removeAllListeners();

How It Works​

Wraps the per-platform APIs described in the .NET MAUI local notifications docs:

  • Android: NotificationManager + NotificationChannel (API 26+) for immediate delivery; AlarmManager + BroadcastReceiver for scheduled delivery; Permissions.PostNotifications (API 33+) runtime permission; schedules are persisted to Preferences, and the RECEIVE_BOOT_COMPLETED broadcast automatically restores not-yet-due alarms after a device reboot.
  • iOS / Mac Catalyst: a shared UNUserNotificationCenter implementation — UNTimeIntervalNotificationTrigger (immediate) / UNCalendarNotificationTrigger (scheduled) + UNUserNotificationCenterDelegate to handle foreground display and taps.
  • Windows: AppNotificationManager (built with AppNotificationBuilder, taps received via NotificationInvoked).

This is the only multi-target plugin in Napacitor (net10.0;net10.0-android;net10.0-ios;net10.0-maccatalyst;net10.0-windows10.0.19041.0): notifications must implement platform callback types (Apple's UNUserNotificationCenterDelegate, Android's BroadcastReceiver, Windows' AppNotificationManager.NotificationInvoked), which are only available under the platform TFMs; the net10.0 target provides stub implementations (methods throw NOT_IMPLEMENTED) so the project still compiles in environments without the platform workloads installed.

Tap routing: platform callback → static Route(id, title, body) → delivered immediately if a JS listener already exists, otherwise queued and flushed when the first listener registers (OnListenerAdded), so no tap is lost.

Android tap delivery paths (cold start only):

  • Cold start (app was killed): the payload is in Activity.Intent; the plugin subscribes to Platform.ActivityStateChanged and resolves the route after the first Activity is created (the plugin is constructed before the Activity exists, so it cannot read CurrentActivity directly);
  • Hot start (app in the foreground): the payload arrives via OnNewIntent, but MAUI exposes no channel a plugin can subscribe to (Platform.OnNewIntent is a static method reserved for AppActions); not supported for now — see Limitations below.

Permissions​

Android​

  • POST_NOTIFICATIONS: on Android 13 (API 33)+ this must be requested at runtime — it is already merged into the host AndroidManifest.xml automatically via [assembly: UsesPermission]; calling requestPermission() shows the system dialog. On lower versions it is always granted.
  • RECEIVE_BOOT_COMPLETED: required to restore schedules after a reboot; already merged into the manifest automatically, no user consent needed.

iOS / Mac Catalyst​

Calling requestPermission() triggers the system authorization dialog (Alert / Sound / Badge).

Windows​

No runtime permission request; whether notifications are shown is decided by the system "Notifications" settings; requestPermission() always returns granted.

Platform Notes​

CapabilityAndroidiOS / Mac CatalystWindowsWeb
Immediate✅✅ (0.25s time trigger)✅✅
Scheduled✅ (AlarmManager)✅ (UNCalendarNotificationTrigger)❌ (not supported by Windows App SDK, throws NOT_IMPLEMENTED)✅ (setTimeout)
Tap callback⚠️ cold start ✅ / hot start ❌✅ (foreground / background / killed)✅ (NotificationInvoked)✅
Restore on reboot✅ (persistence + BootReceiver)✅ (system-persisted, no work needed)——

Limitations​

  • Windows scheduled notifications: the Windows App SDK does not yet offer scheduled notifications; schedule() throws when at is non-empty. See feature request #5050.
  • Android hot-start taps: when the app is in the foreground and a notification is tapped, the payload arrives via OnNewIntent, but MAUI provides no subscribable channel for plugins (Platform.OnNewIntent is a static method reserved for AppActions), so notificationReceived is not triggered in that scenario. If needed, a generic OnNewIntent forwarding mechanism must be introduced in the Napacitor host template (see the ConfigureEssentials forwarding pattern used by the app-actions plugin).
  • Android device reboot: after a reboot only not-yet-due schedules are restored (already-expired ones are not re-fired); restoration relies on the RECEIVE_BOOT_COMPLETED broadcast, and a few domestic ROMs require the user to allow app auto-start in system settings.
  • iOS / Mac Catalyst cold-start taps: the system requires the notification delegate to be registered before the app's didFinishLaunching returns in order to receive the tap callback. This plugin constructs and registers the UNUserNotificationCenterDelegate in CreateMauiApp (i.e. inside FinishedLaunching), which satisfies the timing, so cold-start taps route correctly; late-arriving JS listeners are also covered by the Pending queue.

API​

requestPermission()​

Requests permission to send local notifications (a no-op on Windows).

Returns: Promise<PermissionStatus>

schedule(options)​

Sends local notifications immediately or on a schedule, returning the final id of each notification.

ParamType
optionsScheduleOptions

Returns: Promise<ScheduleResult>

cancel(options)​

Cancels scheduled / delivered notifications.

ParamType
optionsCancelOptions

Returns: Promise<void>

addListener('notificationReceived', callback)​

Listens for the user tapping a notification (fired when the app is woken up or already in the foreground).

ParamType
eventName'notificationReceived'
callbackNotificationReceivedCallback

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

removeAllListeners()​

Removes all listeners for this plugin.

Returns: Promise<void>

Interfaces​

LocalNotificationSchema​

PropTypeDescription
titlestringNotification title.
bodystringNotification body.
idnumberUnique notification id (used for cancellation and tap callbacks); auto-generated when omitted.
atstringScheduled send time (ISO 8601); sends immediately when omitted.

ScheduleOptions​

PropType
notificationsLocalNotificationSchema[]

ScheduleResult​

PropType
notificationsScheduledNotification[]

ScheduledNotification​

PropTypeDescription
idnumberNotification id (the assigned value when auto-generated).

CancelOptions​

PropType
notificationsCancelNotificationSchema[]

CancelNotificationSchema​

PropTypeDescription
idnumberThe id of the notification to cancel.

PermissionStatus​

PropTypeDescription
grantedbooleanWhether notification permission was granted.

NotificationReceived​

PropTypeDescription
idnumberNotification id (0 when the platform cannot provide it).
titlestringNotification title.
bodystringNotification body.