https://www.jianshu.com/p/862885bd8ea2
其实,1、2都可以认为是广义上的scheme方式,只是applinks将scheme限定为"http/https"。
官方介绍
https://domain.name/.well-known/assetlinks.json
https://hostname/.well-known/assetlinks.json
对于moblink来说,就是:
https://z.t4m.cn/.well-known/assetlinks.json
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example",
"sha256_cert_fingerprints":
["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"]
}
}]
使用以下命令确认:
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://domain.name:optional_port&relation=delegate_permission/common.handle_all_urls
对于moblink来说,就是:
https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://z.t4m.cn&relation=delegate_permission/common.handle_all_urls
页面输出为:
使用以下命令验证
adb shell am start -W -a android.intent.action.VIEW -d
// 以下命令无法验证DeepLink,除非你的DeepLink配了android.intent.category.BROWSABLE
adb shell am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://domain.name:optional_port"
Create Deep Links to App Content
比如验证moblink demo的applink功能,输入:
adb shell am start -W -a android.intent.action.VIEW -d "http://z.t4m.cn/YfyIV3" com.mob.moblink.demo
// 或者
adb shell am start -W -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "http://z.t4m.cn/YfyIV3"
Starting: Intent { act=android.intent.action.VIEW dat=http://z.t4m.cn/... pkg=com.mob.moblink.demo }
Status: ok
Activity: com.mob.moblink.demo/.ActivityC
ThisTime: 206
TotalTime: 12951
WaitTime: 448
Complete
上述命令执行时通过sharesdklog可以监测到MobLinkActivity启动时的intent为:
uri: http://z.t4m.cn/YfyIV3,
intent:Intent { act=android.intent.action.VIEW dat=http://z.t4m.cn/... flg=0x10000000 pkg=com.mob.moblink.demo cmp=com.mob.moblink.demo/com.mob.moblink.MobLinkActivity },
activity:com.mob.moblink.MobLinkActivity@e660546
比如验证moblink demo的Scheme跳转功能,输入:
adb shell am start -W -a android.intent.action.VIEW -d "mlink://com.mob.moblink.demo" com.mob.moblink.demo
Starting: Intent { act=android.intent.action.VIEW dat=mlink://com.mob.moblink.demo pkg=com.mob.moblink.demo }
Status: timeout
Activity: com.sec.android.app.launcher/.activities.LauncherActivity
WaitTime: 12383
Complete
上述命令执行时通过sharesdklog可以监测到MobLinkActivity启动时的intent为:
uri: mlink://com.mob.moblink.demo,
intent:Intent { act=android.intent.action.VIEW dat=mlink://com.mob.moblink.demo flg=0x10000000 pkg=com.mob.moblink.demo cmp=com.mob.moblink.demo/com.mob.moblink.MobLinkActivity },
activity:com.mob.moblink.MobLinkActivity@87f5b67
当然,也可以输入完整的scheme以测试是否能恢复场景。
以下面的链接为例:
http://z.t4m.cn/YfyIV3
它跳转时对应的scheme为(其中的params参数可以使用urlEncoded,也可以不用):
adb shell am start -W -a android.intent.action.VIEW -d "mlink://com.mob.moblink.demo/?params=37x0iEF6LcBM/hr6GOXjw82fCtOFrtiBeUTABWGrR96E4pp/JUMxv+CBhT/lAMdRMX84308An4nlzWU7toUs2K1eeA66ycfjTR+PHJ51RRfMWOnoflYGnVGzaIpmLrTcDYwGDS54zwgMU6PSzI8Kc6x83S6JbGqCH+w9PkeBOtfqPy5pp+pXyfQ5M+k9eopdcw7LfJb1zISWRMeTY44ojJ4C5evJYXc+d8ZaypoywIDFQfYpZZ4F/YER8/bFZbwJDbYMjz5NZvusxVq8/EO+dX97aCZAy0kswNK34VIHAoWxkEd4ZJdgQggRpKaHHfK9biVupeWU4k7sI6CI1XMIQY1B3kLqUkT8EXd0+q06Dgg=" com.mob.moblink.demo
运行后就可以正常拉起应用并还原,控制台输出:
Status: ok
Activity: com.mob.moblink.demo/.ActivityC
ThisTime: 479
TotalTime: 36809
WaitTime: 1054
Complete