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
# 不需要做任何额外接入工作
# 配置已集成到脚本里
- App Links
assetlinks.json - 通过 https://${your applinks domain}/.well-known/assetlinks.json 链接可访问
示例:
https://${your applinks domain}/universal_link/${example_app}/link_kit/
[
{
"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"
]
}
}
]
# Deep Link
adb shell am start -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "flk:///power"
# 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"
# 不需要做任何额外接入工作
# 配置已集成到脚本里
- 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/
{
"applinks": {
"apps": [],
"details": [
{
"appID": "${your team id}.${your app bundle id}",
"paths": [
"/universal_link/${example_app}/link_kit/*"
]
}
]
}
}
⚠️ 很多 SDK 都会用到 universal_link,可为不同 SDK 分配不同的 path 以作区分
# Deep Link
xcrun simctl openurl booted flk:///power
# Universal Links
xcrun simctl openurl booted https://www.yourdomain.com/universal_link/example_app/link_kit/power
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/ # 可选配置
# Android
# 修改配置后,必须执行 flutter clean 清理中间编译产物 BuildConfig.java
# step.1 切换工作目录
cd example/
# step.2
flutter clean && flutter pub get
# 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
_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;
});
});