简体   繁体   English

IBM Worklight 6.0-在BlackBerry 10中window.open()失败

[英]IBM Worklight 6.0 - window.open() fails in BlackBerry 10

I had this working in Worklight 5, but I don't seem to be able to get it to work in V6. 我曾在Worklight 5中使用此功能,但似乎无法在V6中使用它。

I'm trying to use the Cordova InAppBrowser in my Worklight app on BlackBerry 10. My code is simple enough: 我试图在BlackBerry 10上的Worklight应用程序中使用Cordova InAppBrowser。我的代码很简单:

window.open(link, "_blank", "location=no");

This works on Android an iOS, but when II run it on the Blackberry 10 simulator, I get the following error in the console log: 这可以在Android和iOS上运行,但是当II在Blackberry 10模拟器上运行时,控制台日志中出现以下错误:

POST http://localhost:8472/org.apache.cordova/isWhitelisted 404 (OK) 

config.xml for my app includes: 我的应用程序的config.xml包括:

<access subdomains="true" uri="*" />

so all links should be whitelisted, but the 404 seems to be for the API call to check whether the link is whitelisted, not for the call to open the link. 因此应将所有链接列入白名单,但404似乎是用于API调用以检查链接是否被列入白名单,而不是用于打开链接的调用。

If I muck with cordova.js to remove the whitelist check from the implementation of open(), the InAppBrowser suddenly works fine, but that file gets overwritten each time I build the app, so customizing it isn't an option. 如果我不愿意使用cordova.js从open()的实现中删除白名单检查,则InAppBrowser突然可以正常工作,但是每次构建应用程序时该文件都会被覆盖,因此自定义它不是一种选择。

Am I missing some configuration needed to make this work? 我是否缺少进行这项工作所需的一些配置?

There seems to be a change in Cordova from 2.0 to 2.3. 科尔多瓦似乎从2.0更改为2.3。 In Worklight V5, the wildcard whitelist access worked, but in V6 on BB10, only specific domains can be whitelisted. 在Worklight V5中,通配符白名单访问有效,但在BB10的V6中,仅特定域可以被列入白名单。

If I add my specific domain as an access element in config.xml, suddenly window.open() works. 如果我将特定域添加为config.xml中的访问元素,则window.open()会突然起作用。 Looking at the blackberry documentation , I think I see why 黑莓文档 ,我想我为什么

If you specify more than one element, the most specific definition is used. 如果指定多个元素,则使用最具体的定义。 For example, if you use http://somedomain.com and http://specific.somedomain.com , the element that uses the first definition (and any features defined under it) is ignored. 例如,如果您使用http://somedomain.comhttp://specific.somedomain.com ,则使用第一个定义(及其下定义的任何功能)的元素将被忽略。

But this leaves me wondering how the wildcard access worked in Worklight V5 (and it does) This same rule should apply to V5 Projects, and I don't see anything in the Cordova docs that changes, but for some reason the wildcard whitelist access works there but not in Worklight V6. 但这让我想知道通配符访问在Worklight V5中是如何工作的(并且确实如此)。该规则应适用于V5项目,并且我在Cordova文档中看不到任何更改,但是由于某些原因,通配符白名单访问有效在那里,但在Worklight V6中却没有。

In any case, I can get window.open() to work so long as I specify all domains specifically in config.xml. 无论如何,只要我在config.xml中专门指定所有域,就可以使window.open()正常工作。 I haven't found a way to successfully whitelist everything. 我还没有找到一种成功将所有内容列入白名单的方法。 I've tried to remove everything but: 我尝试删除所有内容,但:

<access subdomains="true" uri="*" />

(this matches what is in config.xml in my pure cordova test app) (这与我的纯Cordova测试应用程序中config.xml中的内容匹配)

But then the app fails connecting to the Worklight server (not quite sure why) 但是随后该应用程序无法连接到Worklight服务器(不太清楚为什么)

Worklight 6.0 uses Cordova v2.6, it could be that the support there for BlackBerry 10 in regards to window.open (which is now really InAppBrowser) is somewhat off. Worklight 6.0使用Cordova v2.6,这可能是因为在window.open(现在实际上是InAppBrowser)方面,BlackBerry 10的支持已关闭。

See if you can play around with it based on the Cordova documentation: 根据Cordova文档查看是否可以使用它:
http://cordova.apache.org/docs/en/2.6.0/cordova_inappbrowser_inappbrowser.md.html http://cordova.apache.org/docs/en/2.6.0/cordova_inappbrowser_inappbrowser.md.html

I realize this question has already been answered, but there's a config.xml setting that you can add that will allow access to any domains, as documented here . 我意识到这个问题已经得到解答,但是您可以添加一个config.xml设置,该设置将允许访问任何域,如此处所述

Just add: 只需添加:

<preference name="WebSecurity" value="disable"/>

To your config.xml and you should be good to go. 转到config.xml,您应该会很好。

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

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