From 0a5859e2f962d4ca4f90498e1599b46d63385cb9 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Mon, 1 May 2023 13:00:19 -0300 Subject: [PATCH] document silent option --- plugins/notification/guest-js/index.ts | 6 +++++- plugins/notification/src/lib.rs | 6 ++++++ plugins/notification/src/models.rs | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/notification/guest-js/index.ts b/plugins/notification/guest-js/index.ts index 13128270..ad021cb4 100644 --- a/plugins/notification/guest-js/index.ts +++ b/plugins/notification/guest-js/index.ts @@ -114,7 +114,7 @@ interface Options { /** * Extra payload to store in the notification. */ - extra?: { [key: string]: any } + extra?: { [key: string]: unknown } /** * If true, the notification cannot be dismissed by the user on Android. * @@ -127,6 +127,10 @@ interface Options { * Automatically cancel the notification when the user clicks on it. */ autoCancel?: boolean + /** + * Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). + */ + silent?: boolean } type ScheduleInterval = { diff --git a/plugins/notification/src/lib.rs b/plugins/notification/src/lib.rs index fab0020f..6e566fe2 100644 --- a/plugins/notification/src/lib.rs +++ b/plugins/notification/src/lib.rs @@ -191,6 +191,12 @@ impl NotificationBuilder { self.data.auto_cancel = true; self } + + /// Changes the notification presentation to be silent on iOS (no badge, no sound, not listed). + pub fn silent(mut self) -> Self { + self.data.silent = true; + self + } } /// Extensions to [`tauri::App`], [`tauri::AppHandle`] and [`tauri::Window`] to access the notification APIs. diff --git a/plugins/notification/src/models.rs b/plugins/notification/src/models.rs index bfcdb582..df2ae5c1 100644 --- a/plugins/notification/src/models.rs +++ b/plugins/notification/src/models.rs @@ -162,6 +162,8 @@ pub struct NotificationData { pub(crate) ongoing: bool, #[serde(default)] pub(crate) auto_cancel: bool, + #[serde(default)] + pub(crate) silent: bool, } fn default_id() -> i32 { @@ -190,6 +192,7 @@ impl Default for NotificationData { extra: Default::default(), ongoing: false, auto_cancel: false, + silent: false, } } }