Flutter iOS端Universal Links配置后仍跳转Safari 缺失步骤排查求助
Flutter iOS端Universal Links不生效遗漏配置排查项
1. AASA文件部署&格式修正
- 必须将文件部署在站点根目录或
.well-known子目录下,禁止设置任何301/302重定向,必须通过HTTPS访问,证书为官方信任的公开证书,不可使用自签名证书 - 配置返回的HTTP Header中
Content-Type必须为application/json,不能添加X-Frame-Options等阻止爬虫抓取的配置,避免苹果官方服务器无法拉取文件 - 移除JSON中混写的新旧版本字段,避免解析冲突,iOS13及以上系统仅保留
appIDs和components字段即可,修正后的参考格式:
{ "applinks": { "details": [ { "appIDs": ["xxxxxxx.com.bundleIdentifier"], "components": [ { "/": "*" } ] } ] }
2. Xcode项目配置校验
- 确认Associated Domains中填写的域名前缀为
applinks:,不要添加HTTP/HTTPS前缀、不要加路径后缀,例:要关联example.com则填写applinks:example.com - 确认Xcode中签名使用的Team ID、Bundle ID和AASA文件中填写的完全一致,无拼写错误
- 确认打包用的Provisioning Profile已更新Associated Domains权限,修改Capabilities后建议清理Xcode缓存、重新生成Profile后再打包测试
3. 原生层回调配置补充
安装uni_links包后需要手动在iOS原生入口添加回调逻辑,否则无法接收链路唤醒事件:
- 若使用Swift版
AppDelegate.swift,添加如下代码:
import UIKit import Flutter import uni_links @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { override func application( _ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? ) -> Bool { GeneratedPluginRegistrant.register(with: self) return super.application(application, didFinishLaunchingWithOptions: launchOptions) } override func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool { return UniLinksPlugin.sharedInstance()?.application(application, continue: userActivity, restorationHandler: restorationHandler) ?? false } }
- 若使用OC版
AppDelegate.m,对应添加continueUserActivity的回调代理即可。
4. 测试操作修正
- 首次安装App时系统会自动拉取对应域名的AASA文件,若拉取失败则Universal Link不会生效,测试前建议卸载原有App、切换稳定网络后重新安装,触发AASA重新拉取
- 不要直接在Safari地址栏输入链接测试,该场景默认不会触发Universal Link跳转,需在备忘录、信息类应用中点击链接,或使用命令
xcrun simctl openurl booted https://你的域名/测试路径测试 - 若域名在Safari打开后下拉页面无App打开横幅,可确认AASA未被系统成功识别,优先排查文件部署问题。
内容的提问来源于stack exchange,提问作者Nour
相关产品推荐
相关产品推荐

