我正在为 React Native 实现通用链接。
我按照以下说明进行操作:https://reactnavigation.org/docs/deep-linking/ 对于 android,它运行良好。 当我尝试为 iOS 做时(关联域我有一些问题)
为此,我遵循了以下说明:https://developer.apple.com/documentation/xcode/supporting-associated-domains?language=objc
"applinks": {
"details": [
{
"appIDs": [
"ABCDE12345.com.example.app",
"ABCDE12345.com.example.app2"
],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link."
},
{
"/": "/buy/*",
"comment": "Matches any URL with a path that starts with /buy/."
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link."
},
{
"/": "/help/*",
"?": {
"articleNumber": "????"
},
"comment": "Matches any URL with a path that starts with /help/ and that has a query item with name 'articleNumber' and a value of exactly four characters."
}
]
}
]
},
"webcredentials": {
"apps": [
"ABCDE12345.com.example.app"
]
},
"appclips": {
"apps": [
"ABCED12345.com.example.MyApp.Clip"
]
}
}
但是当我查看 ubereats.com 或 facebook 时 https://app-site-association.cdn-apple.com/a/v1/ubereats.com
apple-app-site-association 的格式不同,它们使用此处定义的格式:https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#// apple_ref/doc/uid/TP40016308-CH12-SW1
{
"applinks": {
"apps": [],
"details": [
{
"appID": "9JA89QQLNQ.com.apple.wwdc",
"paths": [ "/wwdc/news/", "/videos/wwdc/2015/*"]
},
{
"appID": "ABCD1234.com.apple.wwdc",
"paths": [ "*" ]
}
]
}
}
那么我应该使用哪种格式或者哪里错了?
终于可以在模拟器上运行,但不能在真实设备上运行
根据 UberEats 和 Facebook 等网站使用的格式,您应该使用 Apple 通用链接文档中定义的格式。
格式应该是这样的:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "your.bundle.id",
"paths": [ "your_desired_path/*"]
}
]
}
}
appID 键应包含您的包 ID,paths 键应指定您的通用链接所需的路径。应用程序密钥应该是空的。
如果它不能在真实设备上运行,请检查您是否在 Xcode 上启用了关联域,以及您的 Apple Developer 帐户中是否设置了正确的 Bundle ID。检查是否
也很重要apple-app-site-association
文件托管在安全服务器 (HTTPS) 上,您的设备可以访问它。
如果用户直接在浏览器中输入 url,iOS 将不会打开带有应用程序的通用链接。只有当用户点击链接时,iOS 才会打开关联的应用程序。
所以,为了测试设置,不要在 Safari 中输入链接,而是使用:
npx uri-scheme open "https://your-side/testpath" --ios
或者,在包含链接的设备上创建提醒(使用提醒应用程序),然后单击它。