具有通配符的iOS关联域(通用链接)不起作用 [英] iOS Associated Domains (Universal Links) with Wildcards not working

查看:321
本文介绍了具有通配符的iOS关联域(通用链接)不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我正在使用的iOS应用中,我已经设置了关联域(通用链接)".该应用程序托管多个域.我已使用通配符设置了某些域.这些域似乎无效.例如,我要链接到https://news.mydomain.com/. 如果我将以下内容添加到关联的域列表中:

In an iOS app I am working on I have setup Associated Domains (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.

推荐答案

我将发现添加到了该线程:

I added my findings to this thread: https://forums.developer.apple.com/thread/47315

简而言之,即使在iOS 10中,通配符设置似乎也要求通配符的根目录提供apple-app-site-association文件.

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.comdomain.com两者中,否则仅在applinks:*.domain.com中指定applinks:*.domain.com不能正常工作. Xcode.

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上,并且在domain.com上具有301重定向(将您重定向到www.domain.com),这是不幸的,因为通用链接不允许重定向.

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文件)
  • server1.app.domain.com(必须服务apple-app-site-association)
  • server2.app.domain.com(...)
  • app.domain.com (must serve the apple-app-site-association file)
  • server1.app.domain.com (must serve the apple-app-site-association)
  • server2.app.domain.com (...)

这样,在Xcode中,您仅可以指定applinks:*.app.domain.com,而通用链接将起作用,而无需在Xcode中指定server1.app.domain.comserver2.app.domain.com等.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆