-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.md
179 lines (139 loc) · 4.03 KB
/
README.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# link_kit
Flutter plugin for Deep Link/App Link/Universal Links.
## ⚠️⚠️⚠️
* link_kit 1.0.0 配置并不与 0.0.x 兼容,请手动删除 0.0.x 配置
* 因为 Android 的 manifestPlaceholders 能力有限,又懒得写需要兼容各版本的 Gradle 插件,所以默认只支持配置一个 DeepLink/AppLink/UniversalLink
## Android
#### 文档
* [创建指向应用内容的深层链接](https://developer.android.com/training/app-links/deep-linking)
* [添加 Android 应用链接](https://developer.android.com/studio/write/app-link-indexing.html)
* [simonmarquis/Android App Linking](https://simonmarquis.github.io/Android-App-Linking/)
* [Statement List Generator and Tester](https://developers.google.com/digital-asset-links/tools/generator)
#### 配置
```
# 不需要做任何额外接入工作
# 配置已集成到脚本里
```
* App Links
assetlinks.json - 通过 https://${your applinks domain}/.well-known/assetlinks.json 链接可访问
示例:
https://${your applinks domain}/universal_link/${example_app}/link_kit/
```json
[
{
"relation": [
"delegate_permission/common.handle_all_urls"
],
"target": {
"namespace": "android_app",
"package_name": "your_app_package_name",
"sha256_cert_fingerprints": [
"your_app_package_fingerprint_sha256"
]
}
}
]
```
> [获取 Android 签名信息](https://github.com/RxReader/wechat_kit#android)
#### 测试
```shell
# Deep Link
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "flk:///power"
```
```shell
# App Link
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "https://www.yourdomain.com/universal_link/example_app/link_kit/power"
```
## iOS
#### 文档
[Support Universal Links](https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html)
#### 配置
```
# 不需要做任何额外接入工作
# 配置已集成到脚本里
```
* Universal Links
apple-app-site-association - 通过 https://${your applinks domain}/.well-known/apple-app-site-association 链接可访问
示例:
https://${your applinks domain}/universal_link/${example_app}/link_kit/
```json
{
"applinks": {
"apps": [],
"details": [
{
"appID": "${your team id}.${your app bundle id}",
"paths": [
"/universal_link/${example_app}/link_kit/*"
]
}
]
}
}
```
> ⚠️ 很多 SDK 都会用到 universal_link,可为不同 SDK 分配不同的 path 以作区分
#### 测试
```shell
# Deep Link
xcrun simctl openurl booted flk:///power
```
```shell
# Universal Links
xcrun simctl openurl booted https://www.yourdomain.com/universal_link/example_app/link_kit/power
```
## Flutter
#### 配置
```yaml
dependencies:
link_kit: ^${latestTag}
# link_kit:
# git:
# url: https://github.com/RxReader/link_kit.git
link_kit:
deep_link: ${your deep link scheme}:///
android:
app_link: https://${your applinks domain}/universal_link/${example_app}/link_kit/ # 可选配置
ios:
universal_link: https://${your applinks domain}/universal_link/${example_app}/link_kit/ # 可选配置
```
#### 安装
```shell
# Android
# 修改配置后,必须执行 flutter clean 清理中间编译产物 BuildConfig.java
# step.1 切换工作目录
cd example/
# step.2
flutter clean && flutter pub get
```
```shell
# iOS
# 首次/修改配置后,必须执行 pod install 让配置生效
# step.0 安装必要依赖
sudo gem install plist
# step.1 切换工作目录
cd example/
# step.2
flutter clean && flutter pub get
# step.3 执行脚本
cd ios/
pod install
```
#### 编码
```dart
_linkClickSubs = LinkKitPlatform.instance.linkClickStream().listen((String event) {
if (kDebugMode) {
print('linkClick: $event');
}
setState(() {
_link = event;
});
});
LinkKitPlatform.instance.getInitialLink().then((String? value) {
if (kDebugMode) {
print('initialLink: $value');
}
setState(() {
_link = value;
});
});
```