简体   繁体   English

PhoneGap Cordova InAppBrowser.open 在 iOS 中切换应用程序之前不会打开链接

[英]PhoneGap Cordova InAppBrowser.open Won't Open Link Until Switching Apps in iOS

I'm having some trouble getting links to open using the InAppBrowser in iOS with a Phonegap/Cordova set up.我在使用 iOS 中的 InAppBrowser 和 Phonegap/Cordova 设置打开链接时遇到了一些问题。

I'm using the default template Cordova provides and adding this line to it:我正在使用 Cordova 提供的默认模板并将此行添加到其中:

<a href="#" onclick="cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');">Testing</a>

When I click the link, nothing happens.当我点击链接时,没有任何反应。

However, when I double-tap the iPhone's home button to switch between apps, then the In-app browser opens as expected (in the view where I can see all open apps I see the browser open).然而,当我双击iPhone的home键切换应用程序之间,那么在应用程序内浏览器打开的预期(在视图中,我可以看到所有打开的应用程序我看到浏览器打开)。 If I navigate back to the app, the browser window now fills the screen as expected.如果我导航回应用程序,浏览器窗口现在会按预期填充屏幕。

What am I doing wrong that's preventing this from opening without the app losing focus?我做错了什么,阻止了它在应用程序失去焦点的情况下打开?

找到了解决方案 - 升级到最新版本的 Cordova(当前为 6.4.0)并使用该版本创建一个新的应用程序似乎可以解决这个问题。

For anyone else who comes across this - the problem is actually caused by iOS failing to trigger the on device ready.对于遇到此问题的任何其他人 - 问题实际上是由 iOS 未能触发设备准备就绪引起的。 This updated meta tag fixed the problem:这个更新的元标记解决了这个问题:

<meta http-equiv="Content-Security-Policy" content="img-src * 'self' data:; default-src * 'self' gap: wss: ws: ; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval';">

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

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