DeepLink简介
在普通Web应用中,DeepLink是我们习以为常的技术,是指通过链接直接定位到指定的资源页面。
URI实例:http://www.test.com/xxx.html
比如可以通过网址直接访问文章。
在移动端,DeepLink是指通过链接直接定位到App的具体位置,而不仅仅是简单唤起APP,也叫做移动端深度链接。
URI实例:myapp://test/spec?param1=p1¶m2=p2
比如我们点击别人分享的h5界面,提示跳转到相应APP界面。
- 移动端深度链接,本质上是使用URI的Schema,移动操作系统提供解析schema的能力,判断schema属于哪个app,唤起并将参数传递给App。
以上图为例:
- APP1必须支持,如微信屏蔽了很多schema,一般手机浏览器不会屏蔽shcema。
- APP2必须支持,APP也需要开发,让系统知道其对应的schema,并解析参数定位到具体位置。
Android深度链接
-
链接唤起APP顺序
1.打开用户指定的首选APP(如果用户指定了URI对应的APP)。
2.打开处理URI的唯一APP。
3.对话框中选择相应的APP(URI对应多个APP的情况) -
指定APP对应的URI Schema
<activity android:name="com.example.android.GizmosActivity" android:label="@string/title_gizmos" > <!-- 设置意图过滤器 --> <intent-filter android:label="@string/filter_view_http_gizmos"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- 解析以"http://www.example.com/gizmos”开头的链接 --> <data android:scheme="http" android:host="www.example.com" android:pathPrefix="/gizmos" /> <!-- 注意: 必须有"/"前缀 --> </intent-filter> <intent-filter android:label="@string/filter_view_example_gizmos"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <!-- 解析以 "myapp://spec”开头的链接 --> <data android:scheme="myapp" android:host="spec" /> </intent-filter> </activity>
- 处理URI链接及参数
//创建Activity时便处理uri,以提升响应速度,获得好的体验。 //可以集中式处理所有的uri的转发 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Intent intent = getIntent(); String action = intent.getAction(); //获取uri Uri data = intent.getData(); }
-
体验建议:
1.直接跳转到目标位置,不要登陆,不要间接页面,可以后续交互中提示用户。可以参考First Click Free的体验建议。
2.遵循向后和向上导航体验设计,与用户通过向后链接进入该位置的体验保持一致。
Deferred DeepLink(延迟深度连接)
当移动设备没有安装对应的APP时,普通的深度链接就无法唤起APP。
延迟深度链接的效果是:点击URI->下载安装文件->安装->唤起APP->定位到指定位置。
相关技术
App Link (Android)
Custom URL Scheme (IOS)
Universal Links (IOS)
常用APP的Schema
微信:weixin://
京东:openapp.jdmoble://
腾讯微博:TencentWeibo://
淘宝:taobao://
支付宝:alipay://
微博:sinaweibo://
百度地图:baidumap://
美团:imeituan://
网易公开课:ntesopen://
作者:铁马-IHorse
邮箱:ihorse2024@hotmail.com