@tauri-apps/plugin-notification
このコンテンツはまだ日本語訳がありません。
Send toast notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API.
Enumerations
Section titled “Enumerations”Importance
Section titled “Importance”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L529
How much the notifications of a Channel interrupt the user.
It maps to the Android NotificationManager.IMPORTANCE_* constants and is only used on Android.
Enumeration Members
Section titled “Enumeration Members”Default
Section titled “Default”Default: 3;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L547
The notifications are shown and make a sound.
This is the value used when the channel does not define an importance.
High: 4;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L551
The notifications are shown, make a sound and pop up as a heads-up notification.
Low: 2;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L541
The notifications are shown without a sound.
Min: 1;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L537
The notifications are only shown in the shade, below the fold, without a status bar icon.
None: 0;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L533
The notifications are not shown.
ScheduleEvery
Section titled “ScheduleEvery”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L190
The unit of the repeating interval used by Schedule.every.
Enumeration Members
Section titled “Enumeration Members”Day: "day";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L214
The notification repeats every day.
Hour: "hour";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L218
The notification repeats every hour.
Minute
Section titled “Minute”Minute: "minute";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L222
The notification repeats every minute.
Month: "month";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L202
The notification repeats every month.
On Android a month is approximated as 30 days.
Second
Section titled “Second”Second: "second";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L228
The notification repeats every second.
Not supported on iOS, where repeating triggers must be at least a minute apart.
TwoWeeks
Section titled “TwoWeeks”TwoWeeks: "twoWeeks";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L206
The notification repeats every two weeks.
Week: "week";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L210
The notification repeats every week.
Year: "year";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L196
The notification repeats every year.
On Android a year is approximated as 52 weeks.
Visibility
Section titled “Visibility”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L559
How much of a notification is shown on the lock screen.
It maps to the Android Notification.VISIBILITY_* constants and is only used on Android.
Enumeration Members
Section titled “Enumeration Members”Private
Section titled “Private”Private: 0;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L569
The notification is shown on the lock screen with its sensitive content hidden.
This is the value used when the channel does not define a visibility.
Public
Section titled “Public”Public: 1;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L573
The notification is shown in full on the lock screen.
Secret
Section titled “Secret”Secret: -1;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L563
The notification is not shown on the lock screen at all.
Classes
Section titled “Classes”Schedule
Section titled “Schedule”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L240
Defines when a scheduled notification is delivered.
Build one with the static Schedule.at, Schedule.interval and
Schedule.every helpers, then pass it to the schedule option of a notification.
Scheduling is only supported on mobile; desktop notifications are always shown immediately.
2.0.0
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Schedule(): Schedule;Returns
Section titled “Returns”Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
at |
| { allowWhileIdle: boolean; date: Date; repeating: boolean; } | undefined |
Set when the notification fires at a fixed date and time. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L244 |
every |
| { allowWhileIdle: boolean; count: number; interval: ScheduleEvery; } | undefined |
Set when the notification repeats on a fixed interval. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L265 |
interval |
| { allowWhileIdle: boolean; interval: ScheduleInterval; } | undefined |
Set when the notification fires whenever the current date matches the given fields. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L255 |
Methods
Section titled “Methods”static at( date, repeating?, allowWhileIdle?): Schedule;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L289
Creates a schedule that fires the notification at the given date and time.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
date |
Date |
undefined |
The date and time the notification fires at. It must be in the future. |
repeating |
boolean |
false |
Whether the notification keeps repeating, using the duration between the moment it is scheduled and date as the interval. The interval must be at least one minute on iOS. |
allowWhileIdle |
boolean |
false |
Whether the notification is allowed to fire while the device is in low-power idle (Doze) mode. Android only. |
Returns
Section titled “Returns”A schedule that can be assigned to the schedule option of a notification.
Example
Section titled “Example”import { Schedule, sendNotification } from '@tauri-apps/plugin-notification';const schedule = Schedule.at(new Date(Date.now() + 60 * 1000));sendNotification({ title: 'Tauri', body: 'One minute later', schedule });every()
Section titled “every()”static every( kind, count, allowWhileIdle?): Schedule;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L341
Creates a schedule that repeatedly fires the notification, once every count interval units.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
kind |
ScheduleEvery |
undefined |
The unit of the repeating interval. |
count |
number |
undefined |
How many interval units elapse between each notification. |
allowWhileIdle |
boolean |
false |
Whether the notification is allowed to fire while the device is in low-power idle (Doze) mode. Android only. |
Returns
Section titled “Returns”A schedule that can be assigned to the schedule option of a notification.
Example
Section titled “Example”import { Schedule, ScheduleEvery, sendNotification } from '@tauri-apps/plugin-notification';const schedule = Schedule.every(ScheduleEvery.Hour, 2);sendNotification({ title: 'Tauri', body: 'Every two hours', schedule });interval()
Section titled “interval()”static interval(interval, allowWhileIdle?): Schedule;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L314
Creates a schedule that fires the notification whenever the current date matches every field set on the given interval.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
interval |
ScheduleInterval |
undefined |
The date fields the current date must match for the notification to fire. |
allowWhileIdle |
boolean |
false |
Whether the notification is allowed to fire while the device is in low-power idle (Doze) mode. Android only. |
Returns
Section titled “Returns”A schedule that can be assigned to the schedule option of a notification.
Example
Section titled “Example”import { Schedule, sendNotification } from '@tauri-apps/plugin-notification';// fires every day at 9:00const schedule = Schedule.interval({ hour: 9, minute: 0 });sendNotification({ title: 'Tauri', body: 'Good morning', schedule });Interfaces
Section titled “Interfaces”Action
Section titled “Action”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L369
A button the user can tap on a notification, belonging to an ActionType.
Only used on mobile. On Android only the identifier, the title and the input flag are used.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
destructive? |
boolean |
Whether the action is displayed as destructive, usually in red. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L389 |
foreground? |
boolean |
Whether the app is brought to the foreground when the action is triggered. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L385 |
id |
string |
The identifier of this action, reported back when the user triggers it. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L373 |
input? |
boolean |
Whether triggering the action lets the user type a text response. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L393 |
inputButtonTitle? |
string |
The text displayed on the button that submits the text input. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L397 |
inputPlaceholder? |
string |
The placeholder displayed on the empty text input field. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L401 |
requiresAuthentication? |
boolean |
Whether the device must be unlocked for the action to run. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L381 |
title |
string |
The text displayed on the action button. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L377 |
ActionType
Section titled “ActionType”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L411
A group of Actions a notification can display, referenced by the
actionTypeId option of a notification.
Register it with registerActionTypes before sending a notification that uses it. Only used on mobile.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
actions |
Action[] |
The list of associated actions | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L419 |
allowInCarPlay? |
boolean |
Whether the notification can be displayed in a CarPlay environment. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L431 |
customDismissAction? |
boolean |
Whether the app is notified when the user dismisses the notification. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L427 |
hiddenPreviewsBodyPlaceholder? |
string |
The placeholder shown instead of the notification body when previews are hidden. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L423 |
hiddenPreviewsShowSubtitle? |
boolean |
Whether the notification subtitle is shown even when previews are hidden. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L439 |
hiddenPreviewsShowTitle? |
boolean |
Whether the notification title is shown even when previews are hidden. iOS only. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L435 |
id |
string |
The identifier of this action type | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L415 |
ActiveNotification
Section titled “ActiveNotification”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L473
A notification that was delivered and is still visible in the notification center.
Returned by active, which is only supported on mobile. Which fields are populated depends on the platform, since Android and iOS expose different information about delivered notifications.
Properties
Section titled “Properties”Attachment
Section titled “Attachment”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L357
Attachment of a notification.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
id |
string |
Attachment identifier. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L359 |
url |
string |
Attachment URL. Accepts the asset and file protocols. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L361 |
Channel
Section titled “Channel”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L582
A notification channel, the category users configure notification behavior on.
Notifications reference a channel through their channelId option and are not delivered
when the channel does not exist. Channels are only supported on Android.
Properties
Section titled “Properties”Options
Section titled “Options”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L25
Options to send a notification.
2.0.0
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
actionTypeId? |
string |
Defines an action type for this notification. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L62 |
attachments? |
Attachment[] |
Notification attachments. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L111 |
autoCancel? |
boolean |
Automatically cancel the notification when the user clicks on it. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L127 |
body? |
string |
Optional notification body. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L44 |
channelId? |
string |
Identifier of the Channel that deliveres this notification. If the channel does not exist, the notification won’t fire. Make sure the channel exists with listChannels and createChannel. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L36 |
extra? |
Record<string, unknown> |
Extra payload to store in the notification. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L115 |
group? |
string |
Identifier used to group multiple notifications. https://developer.apple.com/documentation/usernotifications/unmutablenotificationcontent/1649872-threadidentifier | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L68 |
groupSummary? |
boolean |
Instructs the system that this notification is the summary of a group on Android. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L72 |
icon? |
string |
Notification icon. On Android the icon must be placed in the app’s res/drawable folder. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L97 |
iconColor? |
string |
Icon color on Android. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L107 |
id? |
number |
The notification identifier to reference this object later. Must be a 32-bit integer. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L29 |
inboxLines? |
string[] |
List of lines to add to the notification. Changes the notification style to inbox. Cannot be used with largeBody. Only supports up to 5 lines. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L91 |
largeBody? |
string |
Multiline text. Changes the notification style to big text. Cannot be used with inboxLines. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L54 |
largeIcon? |
string |
Notification large icon (Android). The icon must be placed in the app’s res/drawable folder. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L103 |
number? |
number |
Sets the number of items this notification represents on Android. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L139 |
ongoing? |
boolean |
If true, the notification cannot be dismissed by the user on Android. An application service must manage the dismissal of the notification. It is typically used to indicate a background task that is pending (e.g. a file download) or the user is engaged with (e.g. playing music). | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L123 |
schedule? |
Schedule |
Schedule this notification to fire on a later time or a fixed interval. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L48 |
silent? |
boolean |
Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L131 |
sound? |
string |
The sound resource name or file path for the notification. ## Platform-specific behavior: - On macOS: use system sounds (e.g., “Ping”, “Blow”) or sound files in the app bundle - On Linux: use XDG theme sounds (e.g., “message-new-instant”) or file paths - On Windows: use file paths to sound files (.wav format) - On Mobile: use resource names | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L83 |
summary? |
string |
Detail text for the notification with largeBody, inboxLines or groupSummary. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L58 |
title |
string |
The title displayed on the notification. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L40 |
visibility? |
Visibility |
Notification visibility. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L135 |
PendingNotification
Section titled “PendingNotification”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L447
A notification that was scheduled and has not been delivered yet.
Returned by pending, which is only supported on mobile.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
body? |
string |
The body of the notification, if it was set. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L459 |
id |
number |
The identifier of the notification. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L451 |
schedule |
Schedule |
The schedule that determines when the notification is delivered. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L463 |
title? |
string |
The title of the notification, if it was set. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L455 |
ScheduleInterval
Section titled “ScheduleInterval”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L148
The set of date fields a scheduled notification must match to be delivered.
Fields that are not set match any value, so the notification fires on every date whose remaining components match.
Properties
Section titled “Properties”Type Aliases
Section titled “Type Aliases”PermissionState
Section titled “PermissionState”type PermissionState = "granted" | "denied" | "prompt" | "prompt-with-rationale";Source: undefined
Functions
Section titled “Functions”active()
Section titled “active()”function active(): Promise<ActiveNotification[]>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L781
Retrieves the list of active notifications.
Returns
Section titled “Returns”A promise resolving to the list of active notifications.
Example
Section titled “Example”import { active } from '@tauri-apps/plugin-notification';const activeNotifications = await active();2.0.0
cancel()
Section titled “cancel()”function cancel(notifications): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L747
Cancels the pending notifications with the given list of identifiers.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
notifications |
number[] |
The identifiers of the pending notifications to cancel. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { cancel } from '@tauri-apps/plugin-notification';await cancel([-34234, 23432, 4311]);2.0.0
cancelAll()
Section titled “cancelAll()”function cancelAll(): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L764
Cancels all pending notifications.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { cancelAll } from '@tauri-apps/plugin-notification';await cancelAll();2.0.0
channels()
Section titled “channels()”function channels(): Promise<Channel[]>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L881
Retrieves the list of notification channels.
Returns
Section titled “Returns”A promise resolving to the list of notification channels.
Example
Section titled “Example”import { channels } from '@tauri-apps/plugin-notification';const notificationChannels = await channels();2.0.0
createChannel()
Section titled “createChannel()”function createChannel(channel): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L845
Creates a notification channel.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
channel |
Channel |
The channel to create. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { createChannel, Importance, Visibility } from '@tauri-apps/plugin-notification';await createChannel({ id: 'new-messages', name: 'New Messages', lights: true, vibration: true, importance: Importance.Default, visibility: Visibility.Private});2.0.0
isPermissionGranted()
Section titled “isPermissionGranted()”function isPermissionGranted(): Promise<boolean>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L635
Checks if the permission to send notifications is granted.
Returns
Section titled “Returns”Promise<boolean>
A promise resolving to whether the permission to send notifications is granted.
Example
Section titled “Example”import { isPermissionGranted } from '@tauri-apps/plugin-notification';const permissionGranted = await isPermissionGranted();2.0.0
onAction()
Section titled “onAction()”function onAction(cb): Promise<PluginListener>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L930
Listens to the actions the user performs on a notification.
Only emitted on mobile, for notifications that reference an action type registered with registerActionTypes.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cb |
(notification) => void |
The closure called with the notification the action was performed on. |
Returns
Section titled “Returns”Promise<PluginListener>
A promise resolving to a listener that can be used to stop listening for the event.
Example
Section titled “Example”import { onAction } from '@tauri-apps/plugin-notification';const unlisten = await onAction((notification) => { console.log(`user acted on notification: ${notification.title}`);});2.0.0
onNotificationReceived()
Section titled “onNotificationReceived()”function onNotificationReceived(cb): Promise<PluginListener>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L904
Listens to notifications that are delivered while the app is running.
Only emitted on mobile.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cb |
(notification) => void |
The closure called with the notification that was delivered. |
Returns
Section titled “Returns”Promise<PluginListener>
A promise resolving to a listener that can be used to stop listening for the event.
Example
Section titled “Example”import { onNotificationReceived } from '@tauri-apps/plugin-notification';const unlisten = await onNotificationReceived((notification) => { console.log(`received notification: ${notification.title}`);});2.0.0
pending()
Section titled “pending()”function pending(): Promise<PendingNotification[]>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L728
Retrieves the list of pending notifications.
Returns
Section titled “Returns”Promise<PendingNotification[]>
A promise resolving to the list of pending notifications.
Example
Section titled “Example”import { pending } from '@tauri-apps/plugin-notification';const pendingNotifications = await pending();2.0.0
registerActionTypes()
Section titled “registerActionTypes()”function registerActionTypes(types): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L711
Register actions that are performed when the user clicks on the notification.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
types |
ActionType[] |
The action types to register. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { registerActionTypes } from '@tauri-apps/plugin-notification';await registerActionTypes([{ id: 'tauri', actions: [{ id: 'my-action', title: 'Settings' }]}])2.0.0
removeActive()
Section titled “removeActive()”function removeActive(notifications): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L800
Removes the active notifications with the given list of identifiers.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
notifications |
object[] |
The active notifications to remove, identified by their id and, on Android, their optional tag. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { removeActive } from '@tauri-apps/plugin-notification';await removeActive([{ id: -34234 }, { id: 23432 }, { id: 4311 }])2.0.0
removeAllActive()
Section titled “removeAllActive()”function removeAllActive(): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L819
Removes all active notifications.
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { removeAllActive } from '@tauri-apps/plugin-notification';await removeAllActive()2.0.0
removeChannel()
Section titled “removeChannel()”function removeChannel(id): Promise<void>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L864
Removes the channel with the given identifier.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
id |
string |
The identifier of the channel to remove. |
Returns
Section titled “Returns”Promise<void>
A promise indicating the success or failure of the operation.
Example
Section titled “Example”import { removeChannel } from '@tauri-apps/plugin-notification';await removeChannel('new-messages');2.0.0
requestPermission()
Section titled “requestPermission()”function requestPermission(): Promise<NotificationPermission>;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L658
Requests the permission to send notifications.
Returns
Section titled “Returns”Promise<NotificationPermission>
A promise resolving to whether the user granted the permission or not.
Example
Section titled “Example”import { isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification';let permissionGranted = await isPermissionGranted();if (!permissionGranted) { const permission = await requestPermission(); permissionGranted = permission === 'granted';}2.0.0
sendNotification()
Section titled “sendNotification()”function sendNotification(options): void;Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L682
Sends a notification to the user.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
options |
string | Options |
The notification content, or the notification title when a string is given. |
Returns
Section titled “Returns”void
Example
Section titled “Example”import { isPermissionGranted, requestPermission, sendNotification } from '@tauri-apps/plugin-notification';let permissionGranted = await isPermissionGranted();if (!permissionGranted) { const permission = await requestPermission(); permissionGranted = permission === 'granted';}if (permissionGranted) { sendNotification('Tauri is awesome!'); sendNotification({ title: 'TAURI', body: 'Tauri is awesome!' });}2.0.0
© 2026 Tauri Contributors. CC-BY / MIT