use tauri::{AppHandle, Runtime};
use tauri_plugin_notification::NotificationExt;
#[derive(Clone)]
pub struct Notifier<R: Runtime> {
pub(crate) app: AppHandle<R>,
}
impl<R: Runtime> Notifier<R> {
pub fn show(&self, title: &str, body: &str) {
if let Err(e) = self
.app
.notification()
.builder()
.title(title)
.body(body)
.show()
{
log::warn!("background-service: notification failed: {e}");
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[allow(dead_code)]
fn notifier_clone_compiles<R: Runtime + Clone>(app: AppHandle<R>) {
let n = Notifier { app };
let _cloned = n.clone();
}
}