iOS Universal Links配置

场景和配置:

app:两个app分别AppA和AppB,

域名:dyhy-web.yndysc.com

配置文件目录: https://dyhy-web.yndysc.com/.well-known/apple-app-site-association

objectivec 复制代码
{
  "applinks": {
    "details": [
      {
    
        "appIDs": ["TeamID.BundleID.AppA"],//开发者账号中查看TeamID
        "components": [
          { "/": "/app/shipper/*" } //AppA的匹配路径
        ]
      },
      {
        "appIDs": ["TeamID.BundleID.AppB"],
        "components": [
          { "/": "/app/carrier/*" } //AppB的匹配路径
        ]
      }
    ]
  }
}

该json文件命名为apple-app-site-association,放在域名跟路径的.well-known下面

xcode配置

Xcode 工程 → 选择 Target → Signing & Capabilities

点击 "+" → 添加 Associated Domains 能力

↓

在 Domains 中添加:applinks:dyhy-web.yndysc.com

这里要注意,两个app下的配置都是一样的applinks:dyhy-web.yndysc.com,

目的请看下面的解析流程

注意:

上面说的是用户手动点击链接比如https://dyhy-web.yndysc.com/app/shipper/123,当配置微信支付等其他流程的话需要在配置的时候把https://dyhy-web.yndysc.com/app/shipper/123传递给微信,然后微信支付完成后可以通过这个链接返回到app

比如:

objectivec 复制代码
    [WXApi registerApp:@"wxb2ff695b7cbd647f" universalLink:@"https://dyhy-web.yndysc.com/app/shipper"];

解析流程:

1. 用户点击链接: https://dyhy-web.yndysc.com/app/shipper/123

2. iOS 提取域名: dyhy-web.yndysc.com

3. 查找安装了哪些 App 关联了这个域名

→ 发现 AppA 和 AppB 都关联了 dyhy-web.yndysc.com

4. 从 Apple CDN 获取 AAS 文件

5. 根据 AAS 文件中的路径规则决定:

  • /app/shipper/* → 应该由 AppA 处理
  • /app/carrier/* → 应该由 AppB 处理

6. 打开相应的 App(AppA)

相关推荐
景彬14 小时前
强制升级 Xcode 后,一个 10 年老项目有哪些改动点
ios
茶底世界之下1 天前
海边书店的阴天:用 Awaking 留住青绿与暖灯
ios·app·产品
布莱克6051 天前
Swift 类详解:从定义、继承到内存管理的完整指南
服务器·开发语言·ios·ssh·swift·类
布莱克6051 天前
Swift 方法详解:实例方法、类型方法与 mutating 机制
服务器·开发语言·ios·ssh·swift·方法
茶底世界之下2 天前
旧电影院的红座椅:用 Awaking 留住放映前的光
ios·app·产品
茶底世界之下3 天前
洗衣房的午后斜光:用 Awaking 把光和影分开
ios·app·产品
我是谁的程序员4 天前
iOS 性能分析在 Windows 上怎么做,用 KXBuild 的 kxdevice 替代 Instruments
后端·ios
开心就好20254 天前
通配符 Bundle ID 和精确 Bundle ID 怎么选,推送、iCloud 能不能用通配符
后端·ios
布莱克6054 天前
Swift 枚举详解:从基础语法到关联值与模式匹配
开发语言·ios·swift·枚举
茶底世界之下4 天前
冬日窗边的早餐:用 Awaking 留住冷光里的暖意
ios·app·产品