Aller au contenu

@tauri-apps/plugin-notification

Ce contenu n’est pas encore disponible dans votre langue.

Send toast notifications (brief auto-expiring OS window element) to your user. Can also be used with the Notification Web API.

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.

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.


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.

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: "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: "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: "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.


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.

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: 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: -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.

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

new Schedule(): Schedule;

Schedule

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

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.

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.

Schedule

A schedule that can be assigned to the schedule option of a notification.

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 });

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.

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.

Schedule

A schedule that can be assigned to the schedule option of a notification.

import { Schedule, ScheduleEvery, sendNotification } from '@tauri-apps/plugin-notification';
const schedule = Schedule.every(ScheduleEvery.Hour, 2);
sendNotification({ title: 'Tauri', body: 'Every two hours', schedule });

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.

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.

Schedule

A schedule that can be assigned to the schedule option of a notification.

import { Schedule, sendNotification } from '@tauri-apps/plugin-notification';
// fires every day at 9:00
const schedule = Schedule.interval({ hour: 9, minute: 0 });
sendNotification({ title: 'Tauri', body: 'Good morning', schedule });

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.

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

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.

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

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.

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

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.

Property Type Description Defined in
actionTypeId? string The identifier of the action type the notification was registered with. iOS only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L536
attachments Attachment[] The attachments of the notification. iOS only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L532
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#L512
data Record<string, string> The platform extras attached to the notification, as string values. Android only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L524
extra Record<string, unknown> The extra payload that was stored in the notification. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L528
group? string The identifier of the group the notification belongs to. Android only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L516
groupSummary boolean Whether the notification is the summary of its group. Android only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L520
id number The identifier of the notification. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L500
schedule? Schedule The schedule the notification was delivered with, if it was scheduled. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L540
sound? string The sound resource name of the notification. iOS only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L544
tag? string The tag the notification was posted with. Android only. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L504
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#L508

Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L380

Attachment of a notification.

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

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.

Property Type Description Defined in
description? string The user visible description of this channel. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L629
id string The identifier of this channel. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L621
importance? Importance How much the notifications of this channel interrupt the user. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L651
lightColor? string The color of the device light, as a color string such as #ff0000. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L643
lights? boolean Whether the notifications of this channel blink the device light. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L639
name string The user visible name of this channel. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L625
sound? string The name of the sound resource played by the notifications of this channel. The resource must be placed in the app’s res/raw folder. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L635
vibration? boolean Whether the notifications of this channel vibrate the device. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L647
visibility? Visibility How much of the notifications of this channel is shown on the lock screen. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L655

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

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

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.

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

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.

Property Type Description Defined in
day? number The day of the month the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L183
hour? number The hour of the day the notification fires on, in the 24-hour clock. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L199
minute? number The minute of the hour the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L203
month? number The month of the year the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L179
second? number The second of the minute the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L207
weekday? number The day of the week the notification fires on. 1 - Sunday 2 - Monday 3 - Tuesday 4 - Wednesday 5 - Thursday 6 - Friday 7 - Saturday Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L195
year? number The year the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L175

type PermissionState = "granted" | "denied" | "prompt" | "prompt-with-rationale";

Source: undefined

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.

Promise<ActiveNotification[]>

A promise resolving to the list of active notifications.

import { active } from '@tauri-apps/plugin-notification';
const activeNotifications = await active();

2.0.0


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.

Parameter Type Description
notifications number[] The identifiers of the pending notifications to cancel.

Promise<void>

A promise indicating the success or failure of the operation.

import { cancel } from '@tauri-apps/plugin-notification';
await cancel([-34234, 23432, 4311]);

2.0.0


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.

Promise<void>

A promise indicating the success or failure of the operation.

import { cancelAll } from '@tauri-apps/plugin-notification';
await cancelAll();

2.0.0


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.

Promise<Channel[]>

A promise resolving to the list of notification channels.

import { channels } from '@tauri-apps/plugin-notification';
const notificationChannels = await channels();

2.0.0


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.

Parameter Type Description
channel Channel The channel to create.

Promise<void>

A promise indicating the success or failure of the operation.

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


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.

Promise<boolean>

A promise resolving to whether the permission to send notifications is granted.

import { isPermissionGranted } from '@tauri-apps/plugin-notification';
const permissionGranted = await isPermissionGranted();

2.0.0


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.
Parameter Type Description
cb (event) => void The closure called with the performed action and the notification it refers to.

Promise<PluginListener>

A promise resolving to a listener that can be used to stop listening for the event.

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


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.

Parameter Type Description
cb (notification) => void The closure called with the notification that was delivered.

Promise<PluginListener>

A promise resolving to a listener that can be used to stop listening for the event.

import { onNotificationReceived } from '@tauri-apps/plugin-notification';
const unlisten = await onNotificationReceived((notification) => {
console.log(`received notification: ${notification.title}`);
});

2.0.0


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.

Promise<PendingNotification[]>

A promise resolving to the list of pending notifications.

import { pending } from '@tauri-apps/plugin-notification';
const pendingNotifications = await pending();

2.0.0


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.

Parameter Type Description
types ActionType[] The action types to register.

Promise<void>

A promise indicating the success or failure of the operation.

import { registerActionTypes } from '@tauri-apps/plugin-notification';
await registerActionTypes([{
id: 'tauri',
actions: [{
id: 'my-action',
title: 'Settings'
}]
}])

2.0.0


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.

Parameter Type Description
notifications object[] The active notifications to remove, identified by their id and, on Android, their optional tag.

Promise<void>

A promise indicating the success or failure of the operation.

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


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.

Promise<void>

A promise indicating the success or failure of the operation.

import { removeAllActive } from '@tauri-apps/plugin-notification';
await removeAllActive()

2.0.0


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.

Parameter Type Description
id string The identifier of the channel to remove.

Promise<void>

A promise indicating the success or failure of the operation.

import { removeChannel } from '@tauri-apps/plugin-notification';
await removeChannel('new-messages');

2.0.0


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.

Promise<NotificationPermission>

A promise resolving to whether the user granted the permission or not.

import { isPermissionGranted, requestPermission } from '@tauri-apps/plugin-notification';
let permissionGranted = await isPermissionGranted();
if (!permissionGranted) {
const permission = await requestPermission();
permissionGranted = permission === 'granted';
}

2.0.0


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.

Parameter Type Description
options string | Options The notification content, or the notification title when a string is given.

void

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