Skip to content

Commit 5327809

Browse files
committed
fix: add ios deeplink adaptation
1 parent d6d26e5 commit 5327809

File tree

3 files changed

+34
-27
lines changed

3 files changed

+34
-27
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleURLTypes</key>
6+
<array>
7+
<dict>
8+
<key>CFBundleURLName</key>
9+
<string>com.kodski.deep-link-example</string>
10+
<key>CFBundleURLSchemes</key>
11+
<array>
12+
<string>taurideeplink</string>
13+
</array>
14+
</dict>
15+
</array>
16+
</dict>
17+
</plist>

plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example_iOS/Info.plist

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,16 @@
4040
<string>UIInterfaceOrientationLandscapeLeft</string>
4141
<string>UIInterfaceOrientationLandscapeRight</string>
4242
</array>
43+
<key>CFBundleURLTypes</key>
44+
<array>
45+
<dict>
46+
<key>CFBundleURLName</key>
47+
<string>com.kodski.deep-link-example</string>
48+
<key>CFBundleURLSchemes</key>
49+
<array>
50+
<string>taurideeplink</string>
51+
</array>
52+
</dict>
53+
</array>
4354
</dict>
4455
</plist>

plugins/deep-link/src/lib.rs

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,36 +76,12 @@ fn init_deep_link<R: Runtime>(
7676
{
7777
return Ok(DeepLink {
7878
app: app.clone(),
79-
current: Default::default(),
80-
config: api.config().clone(),
8179
plugin_handle: handle,
80+
current: Default::default(),
8281
})
8382
}
8483
}
8584

86-
#[cfg(target_os = "ios")]
87-
{
88-
89-
let _api = api;
90-
91-
use tauri::{
92-
ipc::{Channel, InvokeResponseBody},
93-
Emitter,
94-
};
95-
96-
#[derive(serde::Deserialize)]
97-
struct Event {
98-
url: String,
99-
}
100-
101-
let handle = _api.register_ios_plugin(init_plugin_deep_link)?;
102-
return Ok(DeepLink {
103-
app: app.clone(),
104-
current: Default::default(),
105-
config: api.config().clone(),
106-
});
107-
}
108-
10985
#[cfg(desktop)]
11086
{
11187
let args = std::env::args();
@@ -120,8 +96,9 @@ fn init_deep_link<R: Runtime>(
12096
}
12197
}
12298

123-
#[cfg(target_os = "android")]
99+
#[cfg(mobile)]
124100
mod imp {
101+
use std::sync::Mutex;
125102
use tauri::{ipc::Channel, plugin::PluginHandle, AppHandle, Runtime};
126103

127104
use serde::{Deserialize, Serialize};
@@ -142,6 +119,8 @@ mod imp {
142119
pub struct DeepLink<R: Runtime> {
143120
pub(crate) app: AppHandle<R>,
144121
pub(crate) plugin_handle: PluginHandle<R>,
122+
#[cfg(target_os = "ios")]
123+
pub(crate) current: Mutex<Option<Vec<url::Url>>>,
145124
}
146125

147126
impl<R: Runtime> DeepLink<R> {
@@ -195,7 +174,7 @@ mod imp {
195174
}
196175
}
197176

198-
#[cfg(not(target_os = "android"))]
177+
#[cfg(not(mobile))]
199178
mod imp {
200179
use std::sync::Mutex;
201180
#[cfg(target_os = "linux")]

0 commit comments

Comments
 (0)