我在世博会论坛上找到了答案,并想在这里发布解决方案,因为我花了几个小时/几天的时间试图找出答案。并一直在这里遇到这个问题。并且由于只能在生产中轻松测试(相对于本地或发布渠道部署)。我想避免其他用户发布带有损坏的通用深度链接的应用程序的痛苦。
世博会的文档在这里不清楚。在 iOS 部分,Expo 的链接指南相当模糊,有些语言不够明确或不够清晰。更糟糕的是,你在 SO 或其他地方找到的所有内容都充满了相互冲突和过时的信息。
虽然OP的问题很可能仅通过此列表中的最后一项来解决,但我想介绍一些我在为后代解决这个问题时遇到的问题,并澄清我一直在努力拼凑的事情:
- appID 基本上是 iOS 团队 ID 的组合,可以在 Apple 开发者控制台的会员资格下找到。并在应用程序商店连接>应用程序>应用程序信息中找到捆绑包ID(或者它也应该在您的app.json中)。
- 苹果的一些文档可能会令人困惑,并且通配符确实可以匹配多个字符。例如,路径“/auth/*”将正确路由路径为“/auth/login”的 url。
- 您不需要签署 AASA 文件。
- 不要在 app.json 中配置的关联域中包含 https 或路径,它应该只是域(例如“applinks:google.com”)。
- AASA 的工作 mime 类型是 application/pkcs7-mime 而不是 application/json
- 你的 AASA 文件可以放在你的根目录中或者 .
well-known
[docs],我建议将其放在两者上,因为这将有助于创建一些冗余。您可以上传一个文件并配置您的服务器来解析同一文件。
- 您需要为您的标识符启用关联域服务。世博会在其文档中说明了这一点,但执行此操作的位置的导航已过时。在开发者门户 >
Certificates, Identifiers & Profiles
> identifiers
> 单击与您的应用程序包 ID 匹配的标识符 >capabilities
> 检查“关联域” 它会告诉您,这将使您的签名配置文件无效,并且您需要一个新的配置文件来部署您的应用程序。只要您处于托管 expo 应用程序中,expo 就会在您创建新版本时为您处理此问题。
- 您面临的主要问题是 AASA 文件或 apple-app-site-association 已经经历了具有不同架构的 3 次不同迭代。每个架构都相当不同,您需要组合所有 3 个架构才能支持所有当前 + 旧版本的 iOS。 OPs 问题中的架构由 iOS 11 和 12 使用,不受 iOS 13+(2019 年发布)的支持。 Expo 的文档对此并不清楚,并且听起来好像显示的版本适用于所有版本,如果您想要添加的功能,您可以使用新架构,但是新架构对于与较新的 iphone 一起使用是绝对必要的。博览会文档已缩小了新模式,因此如果您不注意,您甚至不会意识到它的存在。
另一位用户在 上深入解释了该解决方案博览会论坛- 我不会深入探讨,但会包括他对我有用的不同模式的组合,以便更容易找到。 (尽管如果您不打算支持低于 iOS 13 的任何版本,新架构可能就足够了。因为 15 是撰写本文时的当前版本)
所有架构组合的示例。
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": [ "TEAMID.bundleidentifier", "ABCDE12345.com.example.app2" ],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
},
{
"/": "/buy/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
},
{
"/": "/help/*",
"?": { "articleNumber": "????" },
"comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"
}
]
},
{
"appID": "TEAMID.bundleidentifier",
"paths": [ "/buy/*", "/help/website/*", "/help/*" ]
},
{
"appID": "OTHTEAMID.otherbundleidentifier",
"paths": [ "/blog", "/blog/post/*" ]
},
{
"appID": "YAOTHTEAMID.yetanotherbundleidentifier",
"paths": [ "*" ]
}
]
},
"activitycontinuation": {
"apps": [
"TEAMID.bundleidentifier",
"OTHTEAMID.otherbundleidentifier"
]
}
新架构示例(如果您不需要支持旧版本的 iOS)
{
"applinks": {
"apps": [],
"details": [
{
"appIDs": ["ABCDE12345.com.example.app", "ABCDE12345.com.example.app2"],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
},
{
"/": "/buy/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
},
{
"/": "/help/*",
"?": { "articleNumber": "????" },
"comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"
}
]
}
]
}