Android无host自定义Deep Link唤起App的intent-filter配置方法
Deep Link无host场景配置方案
核心配置逻辑
你需要匹配的testapp://payload=12345属于无标准域名host的Deep Link,根据匹配范围需求可选择以下两种配置:
方案1:全量匹配所有同scheme链接(兼容性最好)
直接省略android:host属性,仅指定scheme即可,所有testapp://开头的链接都会触发该intent-filter:
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="testapp" /> </intent-filter>
配置生效后,在接收跳转的Activity中通过getIntent().getData()即可获取完整Deep Link内容,自行解析提取payload参数即可。
方案2:限制仅匹配payload开头的链接
如果应用需要同时适配同scheme下带标准host的其他Deep Link,可通过host通配符缩小匹配范围:
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="testapp" android:host="payload*" /> </intent-filter>
该配置会过滤掉testapp://www.xxx.com这类带标准域名的链接,仅匹配host段以payload开头的Deep Link。
异常排查
如果在微信、QQ等第三方应用中点击链接无法唤起,优先到系统浏览器输入该链接测试:
- 浏览器可正常唤起:属于第三方应用的链接识别拦截规则,可申请平台白名单,或者调整Deep Link格式为
testapp:///payload=12345(三个斜杠代表host为空),对应配置调整为:
<intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="testapp" android:host="" android:pathPattern="/payload=.*" /> </intent-filter>
- 浏览器无法唤起:检查manifest配置是否有拼写错误,intent-filter是否绑定到了正确的Activity。
内容的提问来源于stack exchange,提问作者Adrian Ivasku
相关产品推荐
相关产品推荐

