我正在我的应用程序上实现通用链接。我遵循了以下链接中的所有指令。AASA创建链接创建AASA文件。
文件内容如下:
{
"applinks": {
"details": [
{
"appIDs": ["44SGDK39BN.com.app.appname"],
"components": [
{
"#": "no_universal_links",
"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
},
{
"/": "/men/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "/women/*",
"comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
},
{
"/": "*",
"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"
}
]
}
]
}
}它被上传到我的服务器上,不需要重定向。
我的权利文件如下图所示。我已附上这份应享权利文件。

并启用关联域,并在签名和功能中添加所需的域。下面的图像是指该部分。

然后,我从Info选项卡中从Project target explorer更新了URL类型
然后在AppDelegateClass上使用以下代码:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {
return false
}
print(url)
print("Path string \(components.path)")
}
}这里print(url)只打印域名,print("Path string \(components.path)")只打印/。我不知道我错过了什么。我想要完整的网址,当用户点击特定的链接。
通用链接的示例Url:www.domainame.com/men/belt/beltname
当使用单击此类型的链接时,此方法仅打印www.domainname.com。
我需要完整的url。但是,我面临着这个问题。两天过去了,我找不到解决办法。任何人都能找到解决办法。请给我建议。
是反向域名,应该是应用程序的包id吗?它会有问题吗?
我的域名不是反向名称的应用程序包id。
更新
当我添加参数时,如下所示,
www.domainname.com\men?test=test
我要走一条完整的路。
再说一遍,我不知道自己被困在哪里了。
发布于 2020-10-05 05:26:31
经过长时间的搜索,我找到了解决办法。
有两种类型的问题。
我想出了办法和客户协调才能做到这一点。然后这个问题解决了。
什么也帮不了我。然后
结构如下:
{
"applinks": {
"details": [
{
"appIDs": [ "4QE5RGHDNN.com.app.iosapp"],
"components": [
{
"/": "/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "*",
"comment": "Matches any URL whose path starts with /buy/"
},
],
"paths": [ "*"]
}
]
}
}以上AASA文件工作正常。
https://stackoverflow.com/questions/64186839
复制相似问题