我有一个cordova项目,我需要使用inappbrowser插件打开一个窗口,里面有一个cordova页面,而“parent”仍然运行。Cordova inappbrowser deviceready never fires
Cordova负载index.html
它使用inappbrowser插件打开frame.html
。
科尔多瓦得到的加载到frame.html
,但deviceready事件从不会触发,并在5秒后,我在控制台frame.html
中得到此错误。
这只发生在使用inappbrowser插件打开的第二个webview内部。
错误:
cordova.js:1183 deviceready has not fired after 5 seconds.
cordova.js:1176 Channel not fired: onFileSystemPathsReady
cordova.js:1176 Channel not fired: onCordovaInfoReady
我搜索了很多,我的结论是,它不是在文档的onload多余的插件或代码的延缓所需火deviceready的onNativeReady事件。
当我删除cordova-plugin-file
和cordova-plugin-file-transfer
时,onFileSystemPathsReady
错误消失。 如果我删除cordova-plugin-device
,则onCordovaInfoReady
错误消失。
但我需要这些插件。
什么导致deviceready事件根本无法启动?
我能做些什么来让它无需移除我需要的插件?
项目信息:
Node version: v4.2.2
Cordova version: 5.4.1
Installed platforms:
android 4.1.1
ios 3.9.2
Installed plugins:
cordova-plugin-bluetoothle 2.4.0 "Bluetooth LE"
cordova-plugin-device 1.1.0 "Device"
cordova-plugin-dialogs 1.2.0 "Notification"
cordova-plugin-file 3.0.0 "File"
cordova-plugin-file-transfer 1.4.0 "File Transfer"
cordova-plugin-inappbrowser 1.1.0 "InAppBrowser"
cordova-plugin-vibration 2.0.0 "Vibration"
cordova-plugin-whitelist 1.2.0 "Whitelist"
de.appplant.cordova.plugin.background-mode 0.6.4 "BackgroundMode"
Config.xml file:
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.test.app" version="0.0.1" xmlns="http://www.w3.org/ns/widgets">
<name>TestApp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<allow-navigation href="http://*/*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
的index.html:
<!DOCTYPE html>
<html >
<head >
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline';" >
<meta name="format-detection" content="telephone=no" >
<meta name="msapplication-tap-highlight" content="no" >
<meta name="viewport" content="user-scalable=no, initial-scale=1, height=device-height, width=device-width" >
<title >Index</title >
<script >
document.addEventListener('deviceready', function()
{
console.log('ready');
win = window.open('frame.html', '_blank', 'location=no', function()
{
console.log(arguments);
});
}, false);
</script >
</head >
<body >
<script type="text/javascript" src="cordova.js" ></script >
</body >
</html >
frame.html:
<!DOCTYPE html>
<html >
<head >
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline';" >
<meta name="format-detection" content="telephone=no" >
<meta name="msapplication-tap-highlight" content="no" >
<meta name="viewport" content="user-scalable=no, initial-scale=1, height=device-height, width=device-width" >
<title >Frame</title >
<script >
window.addEventListener('deviceready', function()
{
console.log('window.deviceready', arguments);
}, false);
document.addEventListener('deviceready', function()
{
console.log('document.deviceready', arguments);
}, false);
</script >
</head >
<body >
<script type="text/javascript" src="cordova.js" ></script >
</body >
</html >
更新:
我使用两个自修改插件(不是导致问题的),也许,这是某种联系:
编辑:
我需要使用inappbrowser插件,因为bluetoothle插件必须在通过另一个框架中的应用程序导航时保持连接。 这些框架还需要能够与海誓山盟进行沟通,并且都可以访问cordova库。
如果有人有其他想法如何做到这一点,我为他们开放。
更新:
我寻找到cl.kunder。网页流量https://github.com/kunder-lab/cl.kunder.webview插件
“deviceready”将调用只有一次,当您的index.html负荷首次。如果你想用你的InAppBrowser加载事件,我想你需要使用InAppBrowser事件,比如“loadstart,loadstop,loaderror,exit”。 不知道这是你寻找的解决方案,但据我了解这是你想要的。 – JDev
@JDev科尔多瓦记录2个频道没有开火。如果我删除使用这两个通道的插件,则设备准备就会**。我希望它与安装的插件一起启动。这2个插件还没有完成加载,否则设备准备好会触发 – x13