simplify config, support iOS

pull/504/head
Lucas Nogueira 2 years ago
parent ba205ee52e
commit 1ab43e8b80
No known key found for this signature in database
GPG Key ID: 7C32FCA95C8C95D7

@ -20,7 +20,3 @@ tauri = { git = "https://github.com/lucasfernog/tauri", branch = "feat/ipc-custo
log = "0.4"
thiserror = "1"
url = "2"
#[patch."https://github.com/lucasfernog/tauri"]
#tauri-build = { path = "C:/Users/Fabian-Lars/dev/FabianLars/tauri-lucas/core/tauri-build" }
#tauri = { path = "C:/Users/Fabian-Lars/dev/FabianLars/tauri-lucas/core/tauri" }

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<activity android:name="${applicationId}.MainActivity" android:exported="true">
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<!-- Each host needs a new intent-filter -->
<data android:host="fabianlars.de" />
<!-- This should also be configurable otherwise the app will trigger on all paths -->
<data android:pathPrefix="/some-path" />
</intent-filter>
</activity>
</application>
</manifest>

@ -2,37 +2,39 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use serde::Deserialize;
use std::process::exit;
#[derive(Clone, serde::Deserialize)]
struct Config {
android: Vec<AndroidConfig>,
#[derive(Deserialize)]
struct AssociatedDomain {
host: String,
#[serde(default, alias = "path-prefix", rename = "pathPrefix")]
path_prefix: Vec<String>,
}
#[derive(Clone, serde::Deserialize)]
struct AndroidConfig {
domain: String,
#[serde(rename = "pathPrefix")]
path_prefix: Option<String>,
#[derive(Deserialize)]
struct Config {
domains: Vec<AssociatedDomain>,
}
// TODO: Consider using activity-alias in case users may have multiple activities in their app.
// TODO: Do we need multiple pathPrefixes? Do we want to support the other path* configs too?
fn intent_filter(domain: &str, path: Option<&str>) -> String {
// TODO: Do we want to support the other path* configs too?
fn intent_filter(domain: &AssociatedDomain) -> String {
format!(
r#"<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="{domain}" />{}
<data android:host="{}" />
{}
</intent-filter>"#,
if let Some(path) = path {
format!("\n <data android:pathPrefix=\"{path}\" />")
} else {
String::new()
}
domain.host,
domain
.path_prefix
.iter()
.map(|prefix| format!(r#"<data android:pathPrefix="{prefix}" />"#))
.collect::<Vec<_>>()
.join("\n ")
)
}
@ -50,15 +52,15 @@ fn main() {
"DEEP LINK PLUGIN",
"activity",
config
.android
.domains
.iter()
.map(|e| intent_filter(&e.domain, e.path_prefix.as_deref()))
.map(intent_filter)
.collect::<Vec<_>>()
.join("\n"),
)
.expect("failed to rewrite AndroidManifest.xml");
/* #[cfg(target_os = "macos")]
#[cfg(target_os = "macos")]
{
tauri_build::mobile::update_entitlements(|entitlements| {
entitlements.insert(
@ -66,12 +68,12 @@ fn main() {
config
.domains
.into_iter()
.map(Into::into)
.map(|d| format!("applinks:{}", d.host).into())
.collect::<Vec<_>>()
.into(),
);
})
.expect("failed to update entitlements");
} */
}
}
}

@ -3,5 +3,5 @@
// SPDX-License-Identifier: MIT
fn main() {
tauri_build::build()
tauri_build::build()
}

@ -1,33 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/Theme.deep_link_example" android:usesCleartextTraffic="${usesCleartextTraffic}">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:launchMode="singleTask" android:label="@string/main_activity_title" android:name=".MainActivity" android:exported="true">
<application
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.deep_link_example"
android:usesCleartextTraffic="${usesCleartextTraffic}">
<activity
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode"
android:launchMode="singleTask"
android:label="@string/main_activity_title"
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<!-- <intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<!- - Each host needs a new intent-filter - ->
<data android:host="fabianlars.de" />
<!- - This should also be configurable otherwise the app will trigger on all paths - ->
<data android:pathPrefix="/intent" />
</intent-filter> -->
<!-- DEEP LINK PLUGIN. AUTO-GENERATED. DO NOT REMOVE. -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="fabianlars.de" />
<data android:pathPrefix="/intent" />
</intent-filter>
@ -35,15 +28,20 @@
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="tauri.app" />
</intent-filter>
<!-- DEEP LINK PLUGIN. AUTO-GENERATED. DO NOT REMOVE. -->
</activity>
<provider android:name="androidx.core.content.FileProvider" android:authorities="${applicationId}.fileprovider" android:exported="false" android:grantUriPermissions="true">
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>
</manifest>

@ -4,7 +4,8 @@
<dict>
<key>com.apple.developer.associated-domains</key>
<array>
<string>applinks:d7d7-177-23-156-174.ngrok-free.app</string>
<string>applinks:fabianlars.de</string>
<string>applinks:tauri.app</string>
</array>
</dict>
</plist>
</plist>

@ -63,9 +63,9 @@
"hello": "world"
},
"deep-link": {
"android": [
{ "domain": "fabianlars.de", "pathPrefix": "/intent" },
{ "domain": "tauri.app" }
"domains": [
{ "host": "fabianlars.de", "pathPrefix": ["/intent"] },
{ "host": "tauri.app" }
]
}
}

Loading…
Cancel
Save