| 1 | use serde::de::DeserializeOwned; |
| 2 | use tauri::{ |
| 3 | plugin::{PluginApi, PluginHandle}, |
| 4 | AppHandle, Runtime, |
| 5 | }; |
| 6 | |
| 7 | #[cfg(target_os = "android")] |
| 8 | const PLUGIN_IDENTIFIER: &str = "com.plugin.admob"; |
| 9 | |
| 10 | #[cfg(target_os = "ios")] |
| 11 | tauri::ios_plugin_binding!(init_plugin_admob); |
| 12 | |
| 13 | // initializes the Kotlin or Swift plugin classes |
| 14 | pub fn init<R: Runtime, C: DeserializeOwned>( |
| 15 | _app: &AppHandle<R>, |
| 16 | api: PluginApi<R, C>, |
| 17 | ) -> crate::Result<Admob<R>> { |
| 18 | #[cfg(target_os = "android")] |
| 19 | let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "AdmobPlugin")?; |
| 20 | #[cfg(target_os = "ios")] |
| 21 | let handle = api.register_ios_plugin(init_plugin_admob)?; |
| 22 | Ok(Admob(handle)) |
| 23 | } |
| 24 | |
| 25 | /// Access to the admob APIs. |
| 26 | pub struct Admob<R: Runtime>(PluginHandle<R>); |
| 27 | |
| 28 | impl<R: Runtime> Admob<R> {} |