通常,App 监听私有短域名strange.com
(不要问我为什么是短域名,因为短信就是按字算钱的,能省一分是一分)地址:
<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:host="strange.com"
android:pathPattern=".*"
android:scheme="https"/>
<data
android:host="strange.com"
android:pathPattern=".*"
android:scheme="http"/>
</intent-filter>
当点击短信中的链接后,系统会自行判断,如果安装了 App 就会出一个弹框让用户选择在 App 中打开还是在浏览器中打开,如图。
<figure>对用户来说要多做一次选择,这绝对不是好的体验。为了解决这个问题,Android 6.0 开始支持 Deep Links,让用户点击链接直达 App。
首先,在 intent-filter 中添加 android:autoVerify="true"
。
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data
android:host="strange.com"
android:scheme="https"/>
</intent-filter>
其次,在私有域下上传一个 json 文件: https://strange.com/.well-known/assetlinks.json
文件内容:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "应用ID",
"sha256_cert_fingerprints":["签名证书指纹"]
}
}
]
系统在安装应用后会自动访问 json 文件进行检验,如果检验通过,用户访问 strange.com
域名下的链接会直接跳转到应用。
必须采用 Universal Links,否则点击还是直接跳转到浏览器。
要实现短信直接唤起 App,Android 可以用 intent-filter
对域名进行监听,但是会出弹框让用户进行选择,为了更好的体验,建议采用 Deep Links 技术方案,只支持 6.0 以上系统;iOS 只能采用 Universal Links 技术方案,只支持 9.0 以上系统。
系统 首选方案 备选方案
Android DeepLinks(Android 6.0+) intent-filter
iOS UniversalLinks(iOS 9.0+) 无,只能跳浏览器
以上答案来自我厂黄仕彪老师的博文《一切为了运营!如何从推广短信链接唤起 App? 》。
* 版权声明 :社区问答内容由互联网用户编辑提交,本社区不拥有所有权,也不承担相关法律责任。如果您发现本社区中有涉嫌侵权、暴力、色情、反
动等言论,欢迎发送邮件至: 进行举报并提供初步证明,一经查实,本社区将立刻删除相关内容。