@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+BroadcastReceiverfor scheduled delivery;Permissions.PostNotifications(API 33+) runtime permission; schedules are persisted toPreferences, and theRECEIVE_BOOT_COMPLETEDbroadcast automatically restores not-yet-due alarms after a device reboot. - iOS / Mac Catalyst: a shared
UNUserNotificationCenterimplementation —UNTimeIntervalNotificationTrigger(immediate) /UNCalendarNotificationTrigger(scheduled) +UNUserNotificationCenterDelegateto handle foreground display and taps. - Windows:
AppNotificationManager(built withAppNotificationBuilder, taps received viaNotificationInvoked).
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 toPlatform.ActivityStateChangedand resolves the route after the first Activity is created (the plugin is constructed before the Activity exists, so it cannot readCurrentActivitydirectly); - Hot start (app in the foreground): the payload arrives via
OnNewIntent, but MAUI exposes no channel a plugin can subscribe to (Platform.OnNewIntentis 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 hostAndroidManifest.xmlautomatically via[assembly: UsesPermission]; callingrequestPermission()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
| Capability | Android | iOS / Mac Catalyst | Windows | Web |
|---|---|---|---|---|
| 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 whenatis 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.OnNewIntentis a static method reserved for AppActions), sonotificationReceivedis not triggered in that scenario. If needed, a genericOnNewIntentforwarding mechanism must be introduced in the Napacitor host template (see theConfigureEssentialsforwarding 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_COMPLETEDbroadcast, 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
didFinishLaunchingreturns in order to receive the tap callback. This plugin constructs and registers theUNUserNotificationCenterDelegateinCreateMauiApp(i.e. insideFinishedLaunching), 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.
| Param | Type |
|---|---|
options | ScheduleOptions |
Returns: Promise<ScheduleResult>
cancel(options)
Cancels scheduled / delivered notifications.
| Param | Type |
|---|---|
options | CancelOptions |
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).
| Param | Type |
|---|---|
eventName | 'notificationReceived' |
callback | NotificationReceivedCallback |
Returns: Promise<PluginListenerHandle> & PluginListenerHandle
removeAllListeners()
Removes all listeners for this plugin.
Returns: Promise<void>
Interfaces
LocalNotificationSchema
| Prop | Type | Description |
|---|---|---|
title | string | Notification title. |
body | string | Notification body. |
id | number | Unique notification id (used for cancellation and tap callbacks); auto-generated when omitted. |
at | string | Scheduled send time (ISO 8601); sends immediately when omitted. |
ScheduleOptions
| Prop | Type |
|---|---|
notifications | LocalNotificationSchema[] |
ScheduleResult
| Prop | Type |
|---|---|
notifications | ScheduledNotification[] |
ScheduledNotification
| Prop | Type | Description |
|---|---|---|
id | number | Notification id (the assigned value when auto-generated). |
CancelOptions
| Prop | Type |
|---|---|
notifications | CancelNotificationSchema[] |
CancelNotificationSchema
| Prop | Type | Description |
|---|---|---|
id | number | The id of the notification to cancel. |
PermissionStatus
| Prop | Type | Description |
|---|---|---|
granted | boolean | Whether notification permission was granted. |
NotificationReceived
| Prop | Type | Description |
|---|---|---|
id | number | Notification id (0 when the platform cannot provide it). |
title | string | Notification title. |
body | string | Notification body. |