// Copyright 2019-2023 Tauri Programme within The Commons Conservancy // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT use tauri::{command, plugin::PermissionState, AppHandle, Runtime, State}; use crate::{Notification, NotificationData, Result}; #[command] pub(crate) async fn is_permission_granted( _app: AppHandle, notification: State<'_, Notification>, ) -> Result> { let state = notification.permission_state()?; match state { PermissionState::Granted => Ok(Some(true)), PermissionState::Denied => Ok(Some(false)), PermissionState::Prompt | PermissionState::PromptWithRationale => Ok(None), } } #[command] pub(crate) async fn request_permission( _app: AppHandle, notification: State<'_, Notification>, ) -> Result { notification.request_permission() } #[command] pub(crate) async fn notify( _app: AppHandle, notification: State<'_, Notification>, options: NotificationData, ) -> Result<()> { let mut builder = notification.builder(); builder.data = options; builder.show() }