feat: add notification module
This commit is contained in:
parent
45bd3650ea
commit
aec31b7e88
8 changed files with 125 additions and 4 deletions
28
examples/test/src/notification.rs
Normal file
28
examples/test/src/notification.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
use anyhow::ensure;
|
||||
use tauri_sys::notification::{self, Permission};
|
||||
|
||||
pub async fn is_permission_granted() -> anyhow::Result<()> {
|
||||
let granted = notification::is_permission_granted().await?;
|
||||
|
||||
ensure!(granted);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn request_permission() -> anyhow::Result<()> {
|
||||
let permission = notification::request_permission().await?;
|
||||
|
||||
ensure!(permission == Permission::Granted);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn show_notification() -> anyhow::Result<()> {
|
||||
let mut n = notification::Notification::default();
|
||||
n.set_title("TAURI");
|
||||
n.set_body("Tauri is awesome!");
|
||||
|
||||
n.show()?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue