fix(android): import mobile module and use State::inner() in commands

This commit is contained in:
Erwan Leboucher committed 2026-07-18 14:31:55 +02:00
1 parent 0208d8a2cb
commit 87378da660
1 file changed
+7 -10
@@ -1,6 +1,8 @@
use tauri::{AppHandle, Runtime};
use serde::{Deserialize, Serialize};
use crate::mobile;
#[derive(Debug, Deserialize)]
pub struct DistributorArgs {
pub name: String,
@@ -22,8 +24,7 @@ pub async fn list_distributors<R: Runtime>(
) -> Result<Vec<String>, String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let plugin = _app.state::<mobile::UnifiedPush<R>>().0.clone();
let plugin = _app.state::<mobile::UnifiedPush<R>>().inner().0.clone();
plugin
.run_mobile_plugin_async::<Vec<String>>("listDistributors", ())
.await
@@ -42,8 +43,7 @@ pub async fn set_distributor<R: Runtime>(
) -> Result<(), String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let plugin = _app.state::<mobile::UnifiedPush<R>>().0.clone();
let plugin = _app.state::<mobile::UnifiedPush<R>>().inner().0.clone();
plugin
.run_mobile_plugin::<()>("setDistributor", args)
.map_err(|e| e.to_string())
@@ -60,8 +60,7 @@ pub async fn register_for_push_notifications<R: Runtime>(
) -> Result<String, String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let plugin = _app.state::<mobile::UnifiedPush<R>>().0.clone();
let plugin = _app.state::<mobile::UnifiedPush<R>>().inner().0.clone();
plugin
.run_mobile_plugin_async::<PushNotificationResponse>(
"registerForPushNotifications",
@@ -83,8 +82,7 @@ pub async fn unregister_for_push_notifications<R: Runtime>(
) -> Result<(), String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let plugin = _app.state::<mobile::UnifiedPush<R>>().0.clone();
let plugin = _app.state::<mobile::UnifiedPush<R>>().inner().0.clone();
plugin
.run_mobile_plugin::<()>("unregisterForPushNotifications", ())
.map_err(|e| e.to_string())
@@ -102,8 +100,7 @@ pub async fn set_token<R: Runtime>(
) -> Result<(), String> {
#[cfg(target_os = "android")]
{
use tauri::Manager;
let plugin = _app.state::<mobile::UnifiedPush<R>>().0.clone();
let plugin = _app.state::<mobile::UnifiedPush<R>>().inner().0.clone();
plugin
.run_mobile_plugin::<()>("setToken", args)
.map_err(|e| e.to_string())