apple-app-site-association nginx

  1. 项目里面配置 applinks:   域名   eg: applinks:baidu.com

        2. 创建 apple-app-site-association 文件,无json等后缀名

eg: appID 构成 teamId + bundleId


{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "2TEAM6D5.com.baidu.TEST",
        "paths": ["*"]
      }
    ]
  }
}

 3. 上传apple-app-site-association到applinks中填写的https服务器根目录或者.well-known目录下。

如果是nginx服务器,可以配置nginx如下:

location /apple-app-site-association {
    add_header Content-Type text/plain;
    root  /.well-known;
    index apple-app-site-association;
}

location /.well-known/apple-app-site-association {
    add_header Content-Type text/plain;
    root /.well-known;
    index apple-app-site-association;
}

确保地址 https://域名/apple-app-site-association 可以访问,就说明大致可以了!

4. 重新安装app,然后就可以测试

关于测试

创建apple-app-site-association文件后,将其上传到 HTTPS Web 服务器的根目录或子目录.well-known。该文件需要可通过 HTTPS 访问(无需任何重定向),地址为https:///apple-app-site-association或https:///.well-known/apple-app-site-association。接下来,您需要处理应用程序中的通用链接

即配置成以后,有3个链接要访问成功才可以:

https://你的域名.com/apple-app-site-association
https://你的域名.com/.well-known/apple-app-site-association
https://app-site-association.cdn-apple.com/a/v1/你的域名.com

最后一个链接是苹果CDN链接,可以理解为只要这个地址像下图一样返回正常,就说明我们配置的AASA文件没有问题

在shell里面运行:

curl -v  https://app-site-association.cdn-apple.com/a/v1/你的域名.com

能够访问到说明正常了!

相关参考如下:关于ios Universal Links apple-app-site-association文件 Not Found的问题_ios_什么香香脆脆我们最爱-华为云开发者联盟

### 正确配置 `apple-app-site-association` 文件的方法 为了使微信开放平台的 iOS 应用能够通过 Universal Links 实现无缝跳转功能,需要正确配置 `apple-app-site-association` 文件。以下是详细的说明: #### 1. **文件内容** `apple-app-site-association` 是一个 JSON 格式的文件,用于定义哪些 URL 路径可以通过 Universal Links 打开特定的应用程序。其基本结构如下[^3]: ```json { "applinks": { "apps": [], "details": [ { "appID": "团队id.bundleIdentifier", "paths": ["/path/to/resource/*"] } ] } } ``` 其中: - `teamId` 是 Apple Developer Program 中分配给开发者的唯一标识符。 - `bundleIdentifier` 是应用程序的 Bundle ID。 #### 2. **放置位置** Apple 的文档规定,此文件应放在网站的根目录下或者 `.well-known/` 子目录中。例如: - 如果域名是 `www.example.com`,则文件路径应该是 `https://www.example.com/.well-known/apple-app-site-association` 或者直接放在 `https://www.example.com/apple-app-site-association` 下[^4]。 需要注意的是,iOS 设备只会缓存第一次加载的 `apple-app-site-association` 文件,因此后续修改需手动清除设备上的缓存或重新安装应用测试新设置[^1]。 #### 3. **服务器端 Nginx 配置** 为了让客户端能顺利读取到该文件,可能需要调整 Web 服务(如 Nginx)的相关配置。以下是一个典型的 Nginx 配置示例[^2]: ```nginx location /apple-app-site-association { charset UTF-8; default_type application/json; add_header Content-Type application/json; return 200 '{"applinks":{"apps":[],"details":[{"appID":"xxxxxxxxxxxxxxx","paths":["/*"]}]}'; } ``` 上述配置会返回一段预设的 JSON 数据作为响应体,并确保 MIME 类型被正确识别为 `application/json`。 #### 4. **验证文件有效性** 完成部署后,可通过浏览器或其他工具访问对应的 URL 来确认文件是否可正常下载并解析。另外也可以借助官方推荐的一些在线检测工具进一步核实是否存在潜在错误。 --- #### 问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值