iOS Universal link

oryx2
2 min readMay 13, 2020

--

iOS9开始支持Universal Link,Universal Link是解决Web与原生App的跳转问题,在此之前都是通过scheme(如微信的 weixin://)来实现从Web跳转

到App。scheme跳转需要处理App未安装的情况,使用Universal link就非常漂亮的解决这个问题。

我们看看Universal Link格式, https://myphotoapp.example.com/albums?albumname=vacation&index=1, Universal Link遵循 Http/Https Link格式,当用户打开Universal Link时,如果有安装对应的App,浏览器就会唤起App,如果没有安装,就会请求Url对应的地址内容。

在App和Web之间无缝衔接!

以下示例就是百度搜索有知乎站点内容时,点就详情就会跳转到知乎App。

Universal Link Sample

具体如何支持Universal Link可以看下Apple Universal Link https://developer.apple.com/ios/universal-links

有两点需要注意:

1.打开Universal Link必须由用户触发,也就是有个点击事件。

2.需要跨域。必须从另一个域名跳转到Universal Link,才会触发。

WebView也支持Universal Link,如果从微信网页中跳转到App就可以使用Universal Link,当然最新版微信开放标签wx-open-launch-app, https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/Wechat_Open_Tag.html也能实现微信网页内跳转到目标App。iOS端就是采用Universal Link实现的。

--

--