main
rs 35 lines 1012 Bytes
Raw
1 use serde::de::DeserializeOwned;
2 use tauri::{
3 plugin::{PluginApi, PluginHandle},
4 AppHandle, Runtime,
5 };
6
7 use crate::models::*;
8
9 #[cfg(target_os = "android")]
10 const PLUGIN_IDENTIFIER: &str = "com.plugin.androidTvCheck";
11
12 // initializes the Kotlin or Swift plugin classes
13 pub fn init<R: Runtime, C: DeserializeOwned>(
14 _app: &AppHandle<R>,
15 api: PluginApi<R, C>,
16 ) -> crate::Result<AndroidTvCheck<R>> {
17 #[cfg(target_os = "android")]
18 let handle = api.register_android_plugin(PLUGIN_IDENTIFIER, "AndroidTvCheckPlugin")?;
19 Ok(AndroidTvCheck(handle))
20 }
21
22 /// Access to the android-tv-check APIs.
23 pub struct AndroidTvCheck<R: Runtime>(PluginHandle<R>);
24
25 impl<R: Runtime> AndroidTvCheck<R> {
26 pub fn check(&self) -> crate::Result<CheckResponse> {
27 match self.0.run_mobile_plugin("check", ()) {
28 Ok(res) => {
29 println!("tauri-plugin-android-tv-check: {:?}", res);
30 Ok(res)
31 }
32 Err(err) => Err(err.into()),
33 }
34 }
35 }