@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
Importance
Enumeration Members
Default
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L285
High
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L286
Low
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L284
Min
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L283
None
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L282
ScheduleEvery
Enumeration Members
Day
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L157
Hour
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L158
Minute
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L159
Month
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L154
Second
Not supported on iOS.
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L163
TwoWeeks
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L155
Week
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L156
Year
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L153
Visibility
Enumeration Members
Private
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L291
Public
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L292
Secret
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L290
Classes
Schedule
Constructors
new Schedule()
Returns
Properties
Property | Type |
---|---|
at | undefined | object |
every | undefined | object |
interval | undefined | object |
Methods
at()
Parameters
Parameter | Type | Default value |
---|---|---|
date | Date | undefined |
repeating | boolean | false |
allowWhileIdle | boolean | false |
Returns
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L190
every()
Parameters
Parameter | Type | Default value |
---|---|---|
kind | ScheduleEvery | undefined |
count | number | undefined |
allowWhileIdle | boolean | false |
Returns
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L209
interval()
Parameters
Parameter | Type | Default value |
---|---|---|
interval | ScheduleInterval | undefined |
allowWhileIdle | boolean | false |
Returns
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L198
Interfaces
Action
Properties
Property | Type |
---|---|
destructive? | boolean |
foreground? | boolean |
id | string |
input? | boolean |
inputButtonTitle? | string |
inputPlaceholder? | string |
requiresAuthentication? | boolean |
title | string |
ActionType
Properties
Property | Type | Description |
---|---|---|
actions | Action [] | The list of associated actions |
allowInCarPlay? | boolean | - |
customDismissAction? | boolean | - |
hiddenPreviewsBodyPlaceholder? | string | - |
hiddenPreviewsShowSubtitle? | boolean | - |
hiddenPreviewsShowTitle? | boolean | - |
id | string | The identifier of this action type |
ActiveNotification
Properties
Property | Type |
---|---|
actionTypeId? | string |
attachments | Attachment [] |
body? | string |
data | Record <string , string > |
extra | Record <string , unknown > |
group? | string |
groupSummary | boolean |
id | number |
schedule? | Schedule |
sound? | string |
tag? | string |
title? | string |
Attachment
Attachment of a notification.
Properties
Property | Type | Description |
---|---|---|
id | string | Attachment identifier. |
url | string | Attachment URL. Accepts the asset and file protocols. |
Channel
Properties
Property | Type |
---|---|
description? | string |
id | string |
importance? | Importance |
lightColor? | string |
lights? | boolean |
name | string |
sound? | string |
vibration? | boolean |
visibility? | Visibility |
Options
Options to send a notification.
Since
2.0.0
Properties
Property | Type | Description |
---|---|---|
actionTypeId? | string | Defines an action type for this notification. |
attachments? | Attachment [] | Notification attachments. |
autoCancel? | boolean | Automatically cancel the notification when the user clicks on it. |
body? | string | Optional notification body. |
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. |
extra? | Record <string , unknown > | Extra payload to store in the notification. |
group? | string | Identifier used to group multiple notifications. |
groupSummary? | boolean | Instructs the system that this notification is the summary of a group on Android. |
icon? | string | Notification icon. On Android the icon must be placed in the app’s |
iconColor? | string | Icon color on Android. |
id? | number | The notification identifier to reference this object later. Must be a 32-bit integer. |
inboxLines? | string [] | List of lines to add to the notification. Changes the notification style to inbox. Cannot be used with Only supports up to 5 lines. |
largeBody? | string | Multiline text. Changes the notification style to big text. Cannot be used with inboxLines . |
largeIcon? | string | Notification large icon (Android). The icon must be placed in the app’s |
number? | number | Sets the number of items this notification represents on Android. |
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). |
schedule? | Schedule | Schedule this notification to fire on a later time or a fixed interval. |
silent? | boolean | Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). |
sound? | string | The sound resource name. Only available on mobile. |
summary? | string | Detail text for the notification with largeBody , inboxLines or groupSummary . |
title | string | Notification title. |
visibility? | Visibility | Notification visibility. |
PendingNotification
Properties
Property | Type |
---|---|
body? | string |
id | number |
schedule | Schedule |
title? | string |
ScheduleInterval
Properties
Property | Type | Description |
---|---|---|
day? | number | - |
hour? | number | - |
minute? | number | - |
month? | number | - |
second? | number | - |
weekday? | number | 1 - Sunday 2 - Monday 3 - Tuesday 4 - Wednesday 5 - Thursday 6 - Friday 7 - Saturday |
year? | number | - |
Type Aliases
Permission
Possible permission values.
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L308
Functions
active()
Retrieves the list of active notifications.
Returns
A promise resolving to the list of active notifications.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L460
cancel()
Cancels the pending notifications with the given list of identifiers.
Parameters
Parameter | Type |
---|---|
notifications | number [] |
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L426
cancelAll()
Cancels all pending notifications.
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L443
channels()
Retrieves the list of notification channels.
Returns
A promise resolving to the list of notification channels.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L554
createChannel()
Creates a notification channel.
Parameters
Parameter | Type |
---|---|
channel | Channel |
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L520
isPermissionGranted()
Checks if the permission to send notifications is granted.
Returns
Promise
<boolean
>
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L320
onAction()
Parameters
Parameter | Type |
---|---|
cb | (notification ) => void |
Returns
Promise
<PluginListener
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L564
onNotificationReceived()
Parameters
Parameter | Type |
---|---|
cb | (notification ) => void |
Returns
Promise
<PluginListener
>
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L558
pending()
Retrieves the list of pending notifications.
Returns
Promise
<PendingNotification
[]>
A promise resolving to the list of pending notifications.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L409
registerActionTypes()
Register actions that are performed when the user clicks on the notification.
Parameters
Parameter | Type |
---|---|
types | ActionType [] |
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L392
removeActive()
Removes the active notifications with the given list of identifiers.
Parameters
Parameter | Type |
---|---|
notifications | object [] |
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L477
removeAllActive()
Removes all active notifications.
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L496
removeChannel()
Removes the channel with the given identifier.
Parameters
Parameter | Type |
---|---|
id | string |
Returns
Promise
<void
>
A promise indicating the success or failure of the operation.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L537
requestPermission()
Requests the permission to send notifications.
Returns
A promise resolving to whether the user granted the permission or not.
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L343
sendNotification()
Sends a notification to the user.
Parameters
Parameter | Type |
---|---|
options | string | Options |
Returns
void
Example
Since
2.0.0
Source: https://github.com/tauri-apps/plugins-workspace/blob/v2/plugins/notification/guest-js/index.ts#L365
© 2024 Tauri Contributors. CC-BY / MIT