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)

相关推荐
wabil4 小时前
【LVGL】滑动切换页面的界面优化实践
开发语言·ios·swift
威武的花瓣4 小时前
调用Page.RegisterAsyncTask()的异步页
ios·iphone
Digitally21 小时前
5 种简易方法:摩托罗拉手机数据迁移至 iPhone 17
ios·智能手机·iphone
EricStone3 天前
VibeCoding工程流程学习二:iOS项目架构
ios·vibecoding
天桥吴彦祖5 天前
判断iOS如何监听手机屏幕是否锁屏
ios
敲代码的鱼6 天前
PDF 预览与签名批注写回 支持安卓 iOS 鸿蒙 UTS插件
android·前端·ios
时光足迹6 天前
uni-app 视频通话实战:康复师与患者视频问诊的 6 个致命 Bug 与解决方案
android·ios·uni-app
时光足迹6 天前
JPush UniApp UTS 插件完全参考手册:API、事件与厂商通道一网打尽
vue.js·ios·uni-app
时光足迹6 天前
极光推送全攻略(下):uni-app 代码实现与 iOS 排查实战
vue.js·ios·uni-app
时光足迹6 天前
极光推送全攻略(上):被iOS证书折磨了三天,我写了一份前端也能看懂的避坑指南
前端·ios·uni-app