コンテンツにスキップ

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

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.

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.


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.

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


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.

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

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

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#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

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.

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#L341

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#L314

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

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

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.

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

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.

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#L513
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#L509
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#L489
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#L501
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#L505
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#L493
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#L497
id number The identifier of the notification. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L477
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#L517
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#L521
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#L481
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#L485

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

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#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

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.

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#L594
id string The identifier of this channel. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L586
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#L616
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#L608
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#L604
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#L590
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#L600
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#L612
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#L620

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

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.

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

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.

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#L160
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#L176
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#L180
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#L156
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#L184
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#L172
year? number The year the notification fires on. Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L152

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#L781

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#L747

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#L764

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#L881

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#L845

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#L635

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

Parameter Type Description
cb (notification) => void The closure called with the notification the action was performed on.

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((notification) => {
console.log(`user acted on notification: ${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#L904

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#L728

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#L711

Register actions that are performed when the user clicks on the notification.

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#L800

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

2.0.0


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.

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#L864

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#L658

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#L682

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