iOS通用链接与通配符无法正常工作 [英] iOS Universal Links with Wildcards not working
问题描述
在我正在开发的iOS应用中,我设置了Universal Links。该应用程序托管多个域。我使用通配符设置了一些域名。这些域似乎不起作用。例如,我想链接到 https://news.mydomain.com/
。
如果我将以下内容添加到关联域列表中:
In an iOS app I am working on I have setup Universal Links. The app hosts multiple domains. Some domains I have set up with a wildcard. These domains do not seem to work. For example, I want to link to https://news.mydomain.com/
.
If I add the following to the list of associated domains:
applinks:*。mydomain.com
- >不起作用
applinks:news.mydomain.com
- >工作正常
所以我相信我确实设置了所有正确的,apple-app-site-association文件设置正常。我甚至可以在两种情况下(使用Charles Proxy)看到apple-app-site-association文件被检索好了。
So I believe I did set up all correct, the apple-app-site-association file is setup fine. I can even see in both cases (using Charles Proxy) the apple-app-site-association file got retrieved ok.
对于通配符,该链接仅在Safari中打开。
In the case of the wildcard, the link only opens in Safari.
当我配置没有通配符的域时,应用程序会打开。
When I configure the domain without a wildcard, the App opens.
我在这里遗漏了什么吗?
我在设备上运行iOS 9.3.2,我正在运行Xcode 7.3.1,它们是今天的最新版本。
Am I missing something here? I am running iOS 9.3.2 on the device and I am running Xcode 7.3.1 which are today the latest versions.
推荐答案
我在此主题中添加了我的发现: https://forums.developer.apple.com / thread / 47315
I added my findings to this thread: https://forums.developer.apple.com/thread/47315
简而言之,即使在iOS 10中,通配符设置似乎也需要 apple-app-站点关联
文件由通配符的根提供。
In short, even in iOS 10, it appears that the wildcard setup requires that the apple-app-site-association
file be served by the wildcard's root.
例如,如果要使用 *。domain .com
,然后 apple-app-site-association
需要托管在两者上,例如 app1.domain .com
和 domain.com
,否则只能指定 applinks:*。domain.com < Xcode中的/ code>。
For instance, if you want to use *.domain.com
, then the apple-app-site-association
needs to be hosted at both, e.g., app1.domain.com
and domain.com
, else it won't work with simply specifying applinks:*.domain.com
in Xcode.
如果您的主站点位于 www.domain.com $ c $,这是不幸的。 c>,并且您在
domain.com上有301重定向
(将您重定向到 www .domain.com
),因为Universal Links不允许重定向。
This is unfortunate if your main site is hosted at www.domain.com
, and that you have a 301 redirect on domain.com
(which redirects you to www.domain.com
), because Universal Links do not allow redirects.
我找到的解决方法是为你的应用创建一个主子域名,并使用子子域作为通配符。例如
The workaround I found was to create a main subdomain for your app, and to use sub-subdomains for the wildcard. E.g.
-
app.domain.com
(必须提供apple-app-site-association
file) -
server1.app.domain.com
(必须提供apple-app-site-association
) -
server2.app.domain.com
(...)
app.domain.com
(must serve theapple-app-site-association
file)server1.app.domain.com
(must serve theapple-app-site-association
)server2.app.domain.com
(...)
这样,在Xcode中,您只能指定 applinks: * .app.domain.com
和Universal Links无需指定 server1.app.domain.com
, server2.app.domain.com
,等等......在Xcode中。
That way, in Xcode, you may only specify applinks:*.app.domain.com
and Universal Links will work without you having to specify server1.app.domain.com
, server2.app.domain.com
, and so on... in Xcode.
但是,请注意,如果您打算使用,还必须明确指定 applinks:app.domain.com
该服务器以及您的应用程序。
Note, however, that you must also explicitly specify applinks:app.domain.com
if you plan on using that server as well with your app.
我希望这会有所帮助。
这篇关于iOS通用链接与通配符无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!