tauri_plugin_remote_push/
lib.rs1use tauri::{
2 plugin::{Builder, TauriPlugin},
3 Manager, Runtime,
4};
5
6pub use models::*;
7
8#[cfg(desktop)]
9mod desktop;
10#[cfg(mobile)]
11mod mobile;
12
13mod commands;
14mod error;
15mod models;
16
17pub use error::{Error, Result};
18
19#[cfg(desktop)]
20use desktop::RemotePush;
21#[cfg(mobile)]
22use mobile::RemotePush;
23
24pub trait RemotePushExt<R: Runtime> {
26 fn remote_push(&self) -> &RemotePush<R>;
27}
28
29impl<R: Runtime, T: Manager<R>> crate::RemotePushExt<R> for T {
30 fn remote_push(&self) -> &RemotePush<R> {
31 self.state::<RemotePush<R>>().inner()
32 }
33}
34
35pub fn init<R: Runtime>() -> TauriPlugin<R, Option<Config>> {
37 Builder::<R, Option<Config>>::new("remote-push")
38 .invoke_handler(tauri::generate_handler![
39 commands::get_token,
40 commands::request_permission
41 ])
42 .setup(|app, api| {
43 let config = api.config().clone();
44 #[cfg(mobile)]
45 let remote_push = mobile::init(app, api, config)?;
46 #[cfg(desktop)]
47 let remote_push = desktop::init(app, api, config)?;
48 app.manage(remote_push);
49 Ok(())
50 })
51 .build()
52}