我有一個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