美文网首页
iOS通用链接 点击链接直接进app

iOS通用链接 点击链接直接进app

作者: DCherry | 来源:发表于2024-09-02 10:57 被阅读0次

一、Xcode中 添加 Associated Domains

打开 Xcode,选择你的项目。
在 Targets 中选择你的应用。
转到 Signing & Capabilities 标签。
点击 + Capability,添加 Associated Domains。
在 Associated Domains 中添加条目,格式如下:
applinks:自家网站域名

applinks:baidu.com

二、 创建 apple-app-site-association 文件

在你的服务器上创建一个名为 apple-app-site-association 的文件(没有扩展名)。
建议放在/.well-known/目录下(根目录也可以)
文件内容如下,替换 your.bundle.identifier 为你应用的 Bundle Identifier,
TEAM_ID:你的 Apple Developer 账户的 Team ID。
paths:指定哪些路径可以触发打开应用,* 表示所有路径。

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "TEAM_ID.your.bundle.identifier",
        "paths": [ "/path/*" ]
      }
    ]
  }
}

参考

Twitter的json:
https://x.com/.well-known/apple-app-site-association
知乎的json
https://www.zhihu.com/.well-known/apple-app-site-association

验证/坑

验证服务器配置结果:

https://branch.io/resources/aasa-validator/#resultsbox

都检查正常了,还是不可以正常跳转:

apple-app-site-association 更新了,苹果不一定会拉,亲测要12个小时左右 苹果才会更新 才会生效 跳转才会成功。
苹果提供了验证方法:
https://developer.apple.com/documentation/technotes/tn3155-debugging-universal-links
终端输入(baidu.com 换成自己的域名) 看到的内容是自己配置的就代表苹果更新了,那就没问题了

sudo swcutil dl -d baidu.com

相关文章

网友评论

      本文标题:iOS通用链接 点击链接直接进app

      本文链接:https://www.haomeiwen.com/subject/hblpkjtx.html