https://news.mydomain.com/
。
如果我将以下内容添加到相关域名列表中:
applinks:*.mydomain.com
-> 不起作用
applinks:news.mydomain.com
-> 正常工作
在使用通配符的情况下,链接只能在Safari中打开。
当我配置没有通配符的域时,应用程序会打开。
我是否漏掉什么了? 我在设备上运行iOS 9.3.2,并且运行的是Xcode 7.3.1,这是今天的最新版本。
https://news.mydomain.com/
。
如果我将以下内容添加到相关域名列表中:
applinks:*.mydomain.com
-> 不起作用
applinks:news.mydomain.com
-> 正常工作
我在此线程中添加了我的发现:https://forums.developer.apple.com/thread/47315
简而言之,即使在iOS 10中,通配符设置似乎也要求apple-app-site-association
文件由通配符的根目录提供。
例如,如果您想使用*.domain.com
,那么apple-app-site-association
需要在app1.domain.com
和domain.com
两者上托管,否则在Xcode中仅指定applinks:*.domain.com
是无法工作的。
如果您的主站点托管在www.domain.com
上,并且您在domain.com
上有一个301重定向(将您重定向到www.domain.com
),则这是不幸的,因为通用链接不允许重定向。
我找到的解决方法是为您的应用创建一个主子域,并使用子子域作为通配符。例如:
app.domain.com
(必须提供apple-app-site-association
文件)server1.app.domain.com
(必须提供apple-app-site-association
文件)server2.app.domain.com
(...)这样,在Xcode中,您只需指定applinks:*.app.domain.com
,通用链接就可以工作了,而无需在Xcode中指定server1.app.domain.com
、server2.app.domain.com
等。
但是,请注意,如果您计划使用该服务器与应用程序一起使用,还必须显式指定applinks:app.domain.com
。
希望这可以帮到您。
iOS 9.3 Beta 2
中,才引入了在applinks
的域部分添加通配符的功能。在9.3 Beta 2发行说明中:
你说你运行在您现在可以使用具有任意子域的通用链接,而不需要将所有应用程序的子域列为完全限定域名。 条目的格式为:
:<[:端口号]其中是“webcredentials”,“activitycontinuation”或“applinks”。
输入条目的部分现在可以选择性地以“*。”作为前缀,以指示通配符子域。例如:
applinks:*.example.com
iOS 9.3.2
上。但是你的deployment target
是否>= iOS 9.3
?如果不是,请尝试更改它。我认为这将解决您的问题。
在这里你可以找到本次发布说明的副本(抱歉,我没有其他公共来源)
编辑:
即使Apple文档说您可以在域上使用通配符,但它们在此方面似乎存在问题:
为了匹配相关域名的所有子域名,您可以在特定域名之前加上 . 以指定通配符(必须有句点)。域名匹配基于applinks条目中最长的子字符串。例如,如果您指定applinks: .mywebsite.com和applinks:* .users.mywebsite.com条目,则对于域emily.users.mywebsite.com的匹配将针对更长的* .users.mywebsite.com条目执行。请注意,* .mywebsite.com的条目不会与mywebsite.com匹配,因为星号后面有句点。要同时启用* .mywebsite.com和mywebsite.com的匹配,请为每个提供单独的applinks条目。苹果已更改AASA文件以支持动态链接,请更改并在关联域中添加:webcredentials:dev.rlogical.com
{
"applinks": {
"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"
}
]
}
]
},
"webcredentials": {
"apps": [ "ABCDE12345.com.example.app" ]
},
"appclips": {
"apps": ["ABCED12345.com.example.MyApp.Clip"]
}
}