Universal Link

1,520 阅读1分钟

2018.1.25 更新

微信iOS客户端 貌似已经禁掉了Universal Link。 详细封堵原理:微信着手封堵 Universal Link - 掘金

什么是 Universal Link ?

应用类点击URL地址能跳转到第三方应用,并可以传值将URL上带的值传递掉第三方应用内。省掉了开启Safari才能启动第三方应用的步骤。

App Search Programming Guide: Support Universal Links

基础搭建方法

  1. 创建apple-app-site-association无后缀Json文件
{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
            },
            {
                "appID": "ABCD1234.com.apple.wwdc",
                "paths": [ "*" ]
            }
        ]
    }
}
  1. 将json网址到服务器上(不管放在哪个位置:必须https://yourhost/apple-app-site-association 能访问的到该json文件)服务器一定要支持HTTPS。
  2. 在Xcode中开启Associated Domains,增加applinks:www.yourhost.com字段配置。

无法正常跳转

  1. 没有正确下载配置文件

Sometimes universal links don't work on iOS 11.2 for newly installed apps. The symptoms are that clicking on a universal link won't open an app that is newly installed on a phone. The universal link takes the user to a web page and is prompted to download the app again.

Through testing here at Branch HQ we've discovered that the Apple App Site Associated Domains file (apple-app-site-association file) isn't always downloaded after the app is installed, either when it's installed from the app store or from Xcode.

Removing the app, restarting the phone, re-installing the app, and waiting a minute or so seems to clear this up. This is a horrible user experience obviously. ios11 - Universal Link broken in iOS 11.2 - Stack Overflow

  1. 手动关闭了 Universal Link

使用面 包屑导航(bread crumbs button) 手动关闭 universal link 了。只针对iOS9-iOS10 ,iOS 11 无面包屑导航。