@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#L564
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#L582
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#L586
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#L576
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#L572
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#L568
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#L213
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#L237
The notification repeats every day.
Hour: "hour";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L241
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#L245
The notification repeats every minute.
Month: "month";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L225
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#L251
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#L229
The notification repeats every two weeks.
Week: "week";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L233
The notification repeats every week.
Year: "year";Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L219
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#L594
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#L604
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#L608
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#L598
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#L263
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#L267 |
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#L288 |
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#L278 |
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#L312
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#L364
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#L337
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#L393
A button the user can tap on a notification, belonging to an ActionType.
On Android only the identifier, the title and the input flag are used. On desktop only the identifier and title 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#L413 |
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#L409 |
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#L397 |
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#L417 |
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#L421 |
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#L425 |
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#L405 |
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#L401 |
ActionPerformed
Section titled “ActionPerformed”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L550
An action the user performed on a notification.
Properties
Section titled “Properties”| Property | Type | Description | Defined in |
|---|---|---|---|
actionId |
string |
The identifier of the performed action, or tap for the notification itself. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L552 |
inputValue |
string | null |
The text entered for an input action, on mobile. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L554 |
notification |
| ActiveNotification | null |
The notification the action was performed on, when the platform reports it. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L556 |
ActionType
Section titled “ActionType”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L435
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. On desktop, the actions become buttons on notifications that reference this type.
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#L443 |
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#L455 |
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#L451 |
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#L447 |
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#L463 |
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#L459 |
id |
string |
The identifier of this action type | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L439 |
ActiveNotification
Section titled “ActiveNotification”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L496
A notification that was delivered and is still visible in the notification center.
Returned by active, which is only supported on mobile, and by onAction on mobile and desktop. Which fields are populated depends on the platform.
Properties
Section titled “Properties”Attachment
Section titled “Attachment”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L380
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#L382 |
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#L384 |
Channel
Section titled “Channel”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L617
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 |
chronometerCountDown? |
boolean |
Sets the Chronometer to count down instead of counting up. This is only relevant if usesChronometer is true. If when is set to a time in the future, the chronometer will count down to zero then stop. Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L162 |
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 |
usesChronometer? |
boolean |
Show the when field as a stopwatch. Instead of presenting when as a timestamp, the notification will show an automatically updating display of the minutes and seconds since when. Useful when showing an elapsed time (like an ongoing phone call or timer). Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L154 |
visibility? |
Visibility |
Notification visibility. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L135 |
when? |
number |
Set the time that the event occurred. Notifications in the panel are sorted by this time. Represented as milliseconds since the epoch (e.g. Date.now()). Android only. |
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L146 |
PendingNotification
Section titled “PendingNotification”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L471
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#L483 |
id |
number |
The identifier of the notification. | Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L475 |
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#L487 |
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#L479 |
ScheduleInterval
Section titled “ScheduleInterval”Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L171
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#L819
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#L785
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#L802
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#L922
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#L886
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#L670
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#L980
Listens to the actions the user performs on a notification.
On mobile it is emitted for notifications that reference an action type
registered with registerActionTypes. On desktop it is emitted when the user
clicks a notification (actionId is tap) or one of its actions, for notifications
shown while a listener existed and as far as the notification server reports it.
Without a listener, desktop notifications are shown without their actions.
Platform-specific
- Windows: a click is only reported while the toast is on screen, not once it moved to the Action Center.
- macOS: two or more actions are shown in an “Options” menu, and a click on the menu button itself reports the first action. Actions are told apart by their title.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
cb |
(event) => void |
The closure called with the performed action and the notification it refers to. |
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((event) => { console.log(`user performed ${event.actionId} on ${event.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#L945
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#L766
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#L749
Register actions that are performed when the user clicks on the notification.
On desktop the actions of a type become the buttons of the notifications that reference it;
only their id and title are used there.
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#L841
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 }])On desktop only notifications shown while an onAction listener existed can be removed, and only on Linux and the BSDs. Calling removeAllActive removes all such notifications.
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#L860
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#L905
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#L693
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#L717
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