Universal Link踩坑与研究

更新 18.02.27html

Universal Link也被微信封堵了。见味精大神的 blog: juejin.im/post/5a5371…
ios


Universal link 简介
git

Apple官方文档连接:developer.apple.com/library/con…github

通用连接是苹果于iOS9时推出的一种无缝跳转技术。web

官方介绍以下:安全

“当您支持通用连接时,iOS用户能够点击连接到您的网站,并没有缝地重定向到已安装的应用程序,而无需经过Safari。若是您的应用未安装,点击连接到您的网站在Safari中打开您的网站。微信

相比以前的custom URL schemes方式,通用连接有如下优势:app

独有.不像 custom URL schemes, 通用连接不会被别的应用声明, 由于他们用标准HTTP或HTTPS连接至您的网站.dom

安全.当用户安装你的应用时,iOS系统会校验你上传至网站的文件以确保您的网站容许您的应用程序表明其打开URLs,只有你能建立和上传这个文件,因此网站与应用之间的关联是安全的.post

灵活.若是您的应用没有安装,通用连接亦会正常运转.当应用没有安装,将会如用户所指望的在safari中打开.

简单.一个URL能够同时供网站与app使用.

私有.其余应用与您的应用之间的交流无需知道您的应用是否安装.”

(url:developer.apple.com/library/con…

建立通用连接

这个按照官方文档按步照班便可,或者参考如下连接:

dev.branch.io/getting-sta…

strivingboy.github.io/blog/2015/0…

通用连接的现状

现状:

1.目前咱们的应用已经支持通用连接,但不能从微信中直接跳转至咱们的应用。

2.用了一段时间以后通用连接失效。

3.对于部分手机偶现的全部APP的通用连接失效问题,已经询问苹果开发人员,目前还没有有回应。

已解决的问题:

1.在微信中没法跳转

由于以前在微信中跳转的domain域是相同的,因此致使从微信中没法跳转至咱们的应用。

按以下操做:

a.在微信中打开的url为 https://a.xxx.com/zzz 的网页

b.点击该网页上通用连接的按钮,通用连接为a.xxx.com/yyy

会发现跳转失败,页面仍在微信网页中打开。

将步骤b中的通用连接改成:b.xxx.com/yyy再点击打开便可顺利跳转至咱们的应用。

苹果官方解释以下:

“When a user is browsing your website in Safari and they tap a universal link to a URLin the same domainas the current webpage, iOS respects the user’s most likely intent and opens the link in Safari.If the user taps a universal link to a URL in a different domain, iOS opens the link in your app.”(url:developer.apple.com/library/con…

即:相同domain的状况下的跳转,iOS系统会认为用户更倾向于在网页中继续跳转,因此不会跳转至对应的应用。

2.用了一段时间以后通用连接失效

缘由: 使用通用连接跳转至咱们应用后,点击状态栏右边的的 xxx.com 按钮,通用连接失效。

点击该按钮会被iOS认为是关闭用应用打开URL的功能。因此以后没法使用应用打开URL。

解决方案:将URL在safari中打开,而后往下拉会发现出现以下图的banner,点击右边的打开按钮便可恢复。

苹果官方解释以下:

When a user taps a universal link that you handle, iOS also examines the user’s recent choices to determine whether to open your app or your website. For example, a user who  has tapped a universal link to open your app can later choose to open your website in Safari by tapping a breadcrumb button in the status bar. After the user makes this choice, iOS  continues to open your website in Safari until the user chooses to open your app by tapping OPEN in the Smart App Banner on the webpage.

(url:developer.apple.com/library/con…

没有解决的一些疑问:

问题现象:部分设备重启以后,通用连接失效

1.为何设备重启以后通用连接会失效?

部分设备重启以后,丢失apple-app-site-association文件,致使url与应用之间的没法关联。从而致使通用连接失效。

2.为何会丢失apple-app-site-association文件?

apple-app-site-association文件丢失属于系统级别的问题,目前没有很好的解释。

3.apple-app-site-association文件会从新下载吗?

目前苹果官方解释是只有在app安装的时候才会去请求下载验证该文件。

“When the app is installed, the system downloads and verifies the site association file for each of its associated domains. If the verification is successful, the app is associated with    the domain.”(url:developer.apple.com/reference/s…

另外有猜想在应用更新时,也会去请求下载该文件。

(见:forums.developer.apple.com/thread/3017…forums.developer.apple.com/thread/6972)

4.该通用连接失效时其余应用的通用连接能生效吗?

因为样本较少,就目前观察的状况而言,设备重启以后的失效会致使全部应用的通用连接失效。

5.有没有能解决的方案?

删除并从新安装应用能够修复,但目前没有确凿的官方解释来佐证。

在stackFlow (stackoverflow.com/questions/3…)以及 苹果开发者论坛    (forums.developer.apple.com/message/156…)上有相似的问题,目前还没有有解答。正在持续关注。

相关文章
相关标签/搜索