简体   繁体   English

如何使iOS通用链接在iframe中工作

[英]How to make iOS universal links work inside an iframe

First, we have an app and our domain supports Universal links on iOS9 and iOS10. 首先,我们有一个应用程序,并且我们的域支持iOS9和iOS10上的通用链接。 On the landing page there is an element with 'href' attribute set to our domain. 在目标网页上,有一个元素的“ href”属性设置为我们的域。 Clicking on it launches our native app or opens UL in the browser. 单击它可启动我们的本机应用程序或在浏览器中打开UL。 This is working. 可以了

However when the same landing page is put inside an iframe(expected use case) that button doesn't work as expected. 但是,如果将相同的着陆页放在iframe(预期的用例)中,则该按钮将无法正常工作。 Instead of launching our app I can see in the Consoles: " https://domain/path/page.html " was not allowed to display insecure content from itms-appss://itunes.apple.com/app/appname/id#######?mt=8. 我没有启动我们的应用程序,而是在控制台中看到:“ https://domain/path/page.html ”不允许显示来自itms-appss://itunes.apple.com/app/appname/id的不安全内容#######?mt = 8。 Which means that UL mechanism didn't work and the browser actually retrieved the URL (which in turn is a simple PHP file sending the Location header redirecting to iTunes) 这意味着UL机制不起作用,浏览器实际上检索到了URL(这又是一个简单的PHP文件,将Location标头重定向到iTunes)

I thought may be there was something with our app or the page or the subdomain so I tried to add similar links for Instagram app. 我以为我们的应用程序或页面或子域可能存在某些内容,因此我尝试为Instagram应用程序添加类似的链接。 That didn't help because behavior was the same: UL mechanism didn't work and browser retrieved contents of the UL. 这没有帮助,因为行为相同:UL机制不起作用,浏览器检索了UL的内容。

Pseudo-HTML: 伪HTML:

<body>
<a href="universal_link">Works</a>

<iframe src="your_random_local_page.html">
    <a href="universal_link">Doesn't work</a>
</iframe>

</body>

Just leave from iframe by 刚从iframe离开

<body>
<a href="universal_link">Works</a>

<iframe src="your_random_local_page.html">
      <a target="_top" href="universal_link">Doesn't work</a>
</iframe>

</body>

It's work fine for me. 对我来说很好。

We need additional detail — there isn't enough here to get the full picture. 我们需要其他细节-这里没有足够的全景。 Ideally, a link to your live landing page would be best, but failing that, at least more info on where the Universal Link is pointing. 理想情况下,最好是到实时登录页面的链接,但如果失败,则至少要提供有关通用链接指向的更多信息。

Preliminarily, I suspect your Universal Link is somehow redirecting to the App Store page, which will be attempting to launch the App Store app itself via the itms-appss:// URI scheme. 最初,我怀疑您的通用链接是否以某种方式重定向到App Store页面,该页面将尝试通过itms-appss:// URI方案本身启动App Store应用程序。 Custom URI scheme redirects within iFrames have been blocked since iOS 9.3 , so this is would be expected behavior. iOS 9.3起 ,iFrame中的自定义URI方案重定向已被阻止 ,因此这是预期的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM