iOS Universal Links 整理

2020-03-29  本文已影响0人  好大一棵树6

本文介绍内容
一、Universal Links 介绍
二、如何配置 Universal Links
三、微信分享如何配置 Universal Links

一、Universal Links 介绍

通过 Universal Links 是在浏览器 safari 或者 webview 中是可以直接打开(或者叫跳转到) APP 的。
查看苹果文档

Universal Links 有 5 个好处

二、如何配置 Universal Links

1)编辑一个 apple-app-site-association
apple-app-site-association 是一个 json 文件,没有 .json 后缀的
例子:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "wwdc/*"]
            }
        ]
    }
}

注释:

2)将 apple-app-site-association 文件放到 https 服务端的根目录或者 .well-known 目录下
例子:
https://<domain>/apple-app-site-association
https://<domain>/.well-known/apple-app-site-association

在浏览器可以查看和浏览
https://<domain>/apple-app-site-association
https://<domain>/.well-known/apple-app-site-association
大家可以查看下微信的例子:
https://help.wechat.com/apple-app-site-association

3)通过一下的链接地址可以检测 json 文件的是否可行
https://search.developer.apple.com/appsearch-validation-tool/
将 https://<domain>/apple-app-site-association 放入搜索,查看是否有效

4)如果域名是 linktest.com
那么 上面的 apple-app-site-association 对应的 Universal Links 就是

https://linktest.com/wwdc/

5)Xcode 中的配置
在 target -> Signing & Capabilities -> Associated Domains里面添加 applinks:linktest.com


image.png

6)在 developer.apple.com 后台创建的 AppID 的时候,勾选 Associated Domains


image.png

三、微信分享如何配置 Universal Links

1)首先编辑 apple-app-site-association json 文件,放到域名目录下面
个人建议是要加入 path 目录,不要只用 * 号替代。

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "9JA89QQLNQ.com.apple.wwdc",
                "paths": [ "wwdc/*"]
            },
            {
                "appID": "xxxxxxxxx.com.apple.news",
                "paths": [ "news/*"]
            },
        ]
    }
}

2)在微信 的后台需要配置 Universal Links 也就是如下的
com.apple.wwdc App 的 Universal Links 为

https://linktest.com/wwdc/

com.apple.news App 的 Universal Links 为

https://linktest.com/news/

3)一个域名支持多个应用吗?是支持的。
可以查看的微信的例子中就配置了多个包名,具体查看
https://help.wechat.com/apple-app-site-association
具体可以查看微信的文档

4)微信分享的时候 Universal Links 在微信后台和 Xcode 里面的 要一致。

上一篇 下一篇

猜你喜欢

热点阅读