Skip to content

Commit dbcbd54

Browse files
committed
feat: android deeplinks
1 parent 27ddcd0 commit dbcbd54

File tree

14 files changed

+109
-38
lines changed

14 files changed

+109
-38
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@
3535
},
3636
"engines": {
3737
"pnpm": "^10.0.0"
38-
}
38+
},
39+
"packageManager": "[email protected]+sha512.5ea8b0deed94ed68691c9bad4c955492705c5eeb8a87ef86bc62c74a26b037b08ff9570f108b2e4dbd1dd1a9186fea925e527f141c648e85af45631074680184"
3940
}

plugins/deep-link/build.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,19 @@ const COMMANDS: &[&str] = &["get_current", "register", "unregister", "is_registe
1010

1111
// TODO: Consider using activity-alias in case users may have multiple activities in their app.
1212
fn intent_filter(domain: &AssociatedDomain) -> String {
13+
let host = domain
14+
.host
15+
.as_ref()
16+
.map(|h| format!(r#"<data android:host="{h}" />"#))
17+
.unwrap_or_default();
18+
1319
format!(
1420
r#"<intent-filter android:autoVerify="true">
1521
<action android:name="android.intent.action.VIEW" />
1622
<category android:name="android.intent.category.DEFAULT" />
1723
<category android:name="android.intent.category.BROWSABLE" />
1824
{}
19-
<data android:host="{}" />
25+
{}
2026
{}
2127
{}
2228
{}
@@ -28,7 +34,7 @@ fn intent_filter(domain: &AssociatedDomain) -> String {
2834
.map(|scheme| format!(r#"<data android:scheme="{scheme}" />"#))
2935
.collect::<Vec<_>>()
3036
.join("\n "),
31-
domain.host,
37+
host,
3238
domain
3339
.path
3440
.iter()
@@ -68,6 +74,17 @@ fn main() {
6874
}
6975

7076
if let Some(config) = tauri_plugin::plugin_config::<Config>("deep-link") {
77+
let errors: Vec<String> = config
78+
.mobile
79+
.iter()
80+
.filter_map(|d| d.validate().err())
81+
.collect();
82+
83+
if !errors.is_empty() {
84+
panic!("Deep link config validation failed:\n{}", errors.join("\n"));
85+
}
86+
87+
7188
tauri_plugin::mobile::update_android_manifest(
7289
"DEEP LINK PLUGIN",
7390
"activity",
@@ -80,15 +97,17 @@ fn main() {
8097
)
8198
.expect("failed to rewrite AndroidManifest.xml");
8299

100+
83101
#[cfg(target_os = "macos")]
84102
{
85103
tauri_plugin::mobile::update_entitlements(|entitlements| {
86104
entitlements.insert(
87105
"com.apple.developer.associated-domains".into(),
88106
config
89107
.mobile
90-
.into_iter()
91-
.map(|d| format!("applinks:{}", d.host).into())
108+
.iter()
109+
.filter_map(|d| d.host.as_ref())
110+
.map(|host| format!("applinks:{}", host).into())
92111
.collect::<Vec<_>>()
93112
.into(),
94113
);

plugins/deep-link/examples/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@tauri-apps/api": "2.7.0",
14-
"@tauri-apps/plugin-deep-link": "2.4.1"
14+
"@tauri-apps/plugin-deep-link": "link:../.."
1515
},
1616
"devDependencies": {
1717
"@tauri-apps/cli": "2.7.1",

plugins/deep-link/examples/app/src-tauri/gen/android/app/build.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ val tauriProperties = Properties().apply {
1414
}
1515

1616
android {
17-
compileSdk = 34
17+
compileSdk = 36
1818
namespace = "com.tauri.deep_link_example"
1919
defaultConfig {
2020
manifestPlaceholders["usesCleartextTraffic"] = "false"
2121
applicationId = "com.tauri.deep_link_example"
2222
minSdk = 24
23-
targetSdk = 34
23+
targetSdk = 36
2424
versionCode = tauriProperties.getProperty("tauri.android.versionCode", "1").toInt()
2525
versionName = tauriProperties.getProperty("tauri.android.versionName", "1.0")
2626
}
@@ -58,9 +58,10 @@ rust {
5858
}
5959

6060
dependencies {
61-
implementation("androidx.webkit:webkit:1.6.1")
62-
implementation("androidx.appcompat:appcompat:1.6.1")
63-
implementation("com.google.android.material:material:1.8.0")
61+
implementation("androidx.webkit:webkit:1.14.0")
62+
implementation("androidx.appcompat:appcompat:1.7.1")
63+
implementation("androidx.activity:activity-ktx:1.10.1")
64+
implementation("com.google.android.material:material:1.12.0")
6465
testImplementation("junit:junit:4.13.2")
6566
androidTestImplementation("androidx.test.ext:junit:1.1.4")
6667
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.0")

plugins/deep-link/examples/app/src-tauri/gen/android/app/src/main/AndroidManifest.xml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,36 @@
2727
<action android:name="android.intent.action.VIEW" />
2828
<category android:name="android.intent.category.DEFAULT" />
2929
<category android:name="android.intent.category.BROWSABLE" />
30-
<data android:scheme="http" />
3130
<data android:scheme="https" />
31+
<data android:scheme="http" />
3232
<data android:host="fabianlars.de" />
33+
34+
3335
<data android:pathPrefix="/intent" />
36+
3437
</intent-filter>
3538
<intent-filter android:autoVerify="true">
3639
<action android:name="android.intent.action.VIEW" />
3740
<category android:name="android.intent.category.DEFAULT" />
3841
<category android:name="android.intent.category.BROWSABLE" />
39-
<data android:scheme="http" />
4042
<data android:scheme="https" />
43+
<data android:scheme="http" />
4144
<data android:host="tauri.app" />
4245

46+
47+
48+
49+
</intent-filter>
50+
<intent-filter android:autoVerify="true">
51+
<action android:name="android.intent.action.VIEW" />
52+
<category android:name="android.intent.category.DEFAULT" />
53+
<category android:name="android.intent.category.BROWSABLE" />
54+
<data android:scheme="w3ds" />
55+
56+
57+
58+
59+
4360
</intent-filter>
4461
<!-- DEEP LINK PLUGIN. AUTO-GENERATED. DO NOT REMOVE. -->
4562
</activity>
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
// Copyright 2019-2023 Tauri Programme within The Commons Conservancy
2-
// SPDX-License-Identifier: Apache-2.0
3-
// SPDX-License-Identifier: MIT
4-
51
package com.tauri.deep_link_example
62

7-
class MainActivity : TauriActivity()
3+
import android.os.Bundle
4+
import androidx.activity.enableEdgeToEdge
5+
6+
class MainActivity : TauriActivity() {
7+
override fun onCreate(savedInstanceState: Bundle?) {
8+
enableEdgeToEdge()
9+
super.onCreate(savedInstanceState)
10+
}
11+
}

plugins/deep-link/examples/app/src-tauri/gen/android/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ buildscript {
44
mavenCentral()
55
}
66
dependencies {
7-
classpath("com.android.tools.build:gradle:8.5.1")
7+
classpath("com.android.tools.build:gradle:8.11.0")
88
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25")
99
}
1010
}

plugins/deep-link/examples/app/src-tauri/gen/android/buildSrc/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ repositories {
1818

1919
dependencies {
2020
compileOnly(gradleApi())
21-
implementation("com.android.tools.build:gradle:8.5.1")
21+
implementation("com.android.tools.build:gradle:8.11.0")
2222
}
2323

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Tue May 10 19:22:52 CST 2022
22
distributionBase=GRADLE_USER_HOME
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
distributionPath=wrapper/dists
55
zipStorePath=wrapper/dists
66
zipStoreBase=GRADLE_USER_HOME

plugins/deep-link/examples/app/src-tauri/gen/apple/deep-link-example.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
CODE_SIGN_ENTITLEMENTS = "deep-link-example_iOS/deep-link-example_iOS.entitlements";
323323
CODE_SIGN_IDENTITY = "iPhone Developer";
324324
CODE_SIGN_STYLE = Automatic;
325-
DEVELOPMENT_TEAM = Q93MBH6S2F;
325+
DEVELOPMENT_TEAM = 7F2T2WK6DR;
326326
ENABLE_BITCODE = NO;
327327
"EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64";
328328
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -356,7 +356,7 @@
356356
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
357357
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
358358
);
359-
PRODUCT_BUNDLE_IDENTIFIER = com.tauri.deep-link-example;
359+
PRODUCT_BUNDLE_IDENTIFIER = com.kodski.deep-link-example;
360360
PRODUCT_NAME = "deep-link-example";
361361
SDKROOT = iphoneos;
362362
TARGETED_DEVICE_FAMILY = "1,2";
@@ -432,7 +432,7 @@
432432
CODE_SIGN_ENTITLEMENTS = "deep-link-example_iOS/deep-link-example_iOS.entitlements";
433433
CODE_SIGN_IDENTITY = "iPhone Developer";
434434
CODE_SIGN_STYLE = Automatic;
435-
DEVELOPMENT_TEAM = Q93MBH6S2F;
435+
DEVELOPMENT_TEAM = 7F2T2WK6DR;
436436
ENABLE_BITCODE = NO;
437437
"EXCLUDED_ARCHS[sdk=iphoneos*]" = "arm64-sim x86_64";
438438
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
@@ -466,7 +466,7 @@
466466
"$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",
467467
"$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",
468468
);
469-
PRODUCT_BUNDLE_IDENTIFIER = com.tauri.deep-link-example;
469+
PRODUCT_BUNDLE_IDENTIFIER = com.kodski.deep-link-example;
470470
PRODUCT_NAME = "deep-link-example";
471471
SDKROOT = iphoneos;
472472
TARGETED_DEVICE_FAMILY = "1,2";

0 commit comments

Comments
 (0)