pub struct NotificationBuilder<R: Runtime> { /* private fields */ }Expand description
The notification builder.
Implementations§
Source§impl<R: Runtime> NotificationBuilder<R>
impl<R: Runtime> NotificationBuilder<R>
Sourcepub fn show(self) -> Result<()>
pub fn show(self) -> Result<()>
Shows the notification.
When no title was set with Self::title, the productName from the Tauri configuration is used instead.
Only the title, body, icon, sound and the actions of the action type
of the notification are used on desktop; the scheduling and grouping options are ignored.
When a handler is registered with Notification::on_action or a JavaScript onAction
listener exists, a click on the notification (tap) or on one of its actions is reported
to them, as far as the notification server reports it. Otherwise the actions of the
notification are not shown, since nothing would receive them.
§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.
The notification is dispatched on a background task, so this returns as soon as the payload is prepared.
§Errors
Returns an error when the notification could not be prepared, e.g. when the path of the running executable cannot be resolved on Windows.
Source§impl<R: Runtime> NotificationBuilder<R>
impl<R: Runtime> NotificationBuilder<R>
Sourcepub fn channel_id(self, id: impl Into<String>) -> Self
pub fn channel_id(self, id: impl Into<String>) -> Self
Sets the identifier of the notification channel that delivers this notification.
If the channel does not exist, the notification won’t fire.
Make sure the channel exists with Notification::list_channels and
Notification::create_channel.
Only used on Android.
Sourcepub fn schedule(self, schedule: Schedule) -> Self
pub fn schedule(self, schedule: Schedule) -> Self
Schedule this notification to fire on a later time or a fixed interval.
Sourcepub fn large_body(self, large_body: impl Into<String>) -> Self
pub fn large_body(self, large_body: impl Into<String>) -> Self
Multiline text.
Changes the notification style to big text.
Cannot be used with inboxLines.
Sourcepub fn summary(self, summary: impl Into<String>) -> Self
pub fn summary(self, summary: impl Into<String>) -> Self
Detail text for the notification with largeBody, inboxLines or groupSummary.
Sourcepub fn action_type_id(self, action_type_id: impl Into<String>) -> Self
pub fn action_type_id(self, action_type_id: impl Into<String>) -> Self
Defines an action type for this notification.
Sourcepub fn group(self, group: impl Into<String>) -> Self
pub fn group(self, group: impl Into<String>) -> Self
Identifier used to group multiple notifications.
Sourcepub fn group_summary(self) -> Self
pub fn group_summary(self) -> Self
Instructs the system that this notification is the summary of a group on Android.
Sourcepub fn sound(self, sound: impl Into<String>) -> Self
pub fn sound(self, sound: impl Into<String>) -> Self
The sound resource name for the notification.
Sourcepub fn inbox_line(self, line: impl Into<String>) -> Self
pub fn inbox_line(self, line: impl Into<String>) -> Self
Append an inbox line to the notification.
Changes the notification style to inbox.
Cannot be used with largeBody.
Only supports up to 5 lines.
Sourcepub fn icon(self, icon: impl Into<String>) -> Self
pub fn icon(self, icon: impl Into<String>) -> Self
Notification icon.
On Android the icon must be placed in the app’s res/drawable folder.
Sourcepub fn large_icon(self, large_icon: impl Into<String>) -> Self
pub fn large_icon(self, large_icon: impl Into<String>) -> Self
Notification large icon (Android).
The icon must be placed in the app’s res/drawable folder.
Sourcepub fn icon_color(self, icon_color: impl Into<String>) -> Self
pub fn icon_color(self, icon_color: impl Into<String>) -> Self
Icon color on Android.
Sourcepub fn attachment(self, attachment: Attachment) -> Self
pub fn attachment(self, attachment: Attachment) -> Self
Append an attachment to the notification.
Sourcepub fn extra(self, key: impl Into<String>, value: impl Serialize) -> Self
pub fn extra(self, key: impl Into<String>, value: impl Serialize) -> Self
Adds an extra payload to store in the notification.
Sourcepub fn ongoing(self) -> Self
pub fn ongoing(self) -> Self
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).
Sourcepub fn auto_cancel(self) -> Self
pub fn auto_cancel(self) -> Self
Automatically cancel the notification when the user clicks on it.