I have a cordova project and i need to use the inappbrowser plugin to open a window with a cordova page inside while the "parent" still runs.
Cordova loads index.html which opens frame.html using the inappbrowser plugin.
Cordova get's loaded into frame.html but the deviceready event never fires and after 5 seconds i get this error in the console of frame.html.
This only happens inside the second webview that is opened using the inappbrowser plugin.
Error :
cordova.js:1183 deviceready has not fired after 5 seconds.
cordova.js:1176 Channel not fired: onFileSystemPathsReady
cordova.js:1176 Channel not fired: onCordovaInfoReady
I searched a lot and i concluded that it is not an excess of plugins or code in the document's onload that delays the onNativeReady event that is required to fire deviceready.
When i remove cordova-plugin-file and cordova-plugin-file-transfer the onFileSystemPathsReady error disappears.
If i remove cordova-plugin-device the onCordovaInfoReady error disappears.
But i need those plugins.
What is causing the deviceready event to not fire at all?
And what can i do to get it to fire without removing the plugins i need?
Project info :
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 >
Update :
I am using two self-modified plugins (not the ones that cause the problem), maybe that this is somehow related:
Edit :
I need to use the inappbrowser plugin because the bluetoothle plugin has to keep the connection while navigating through the app in the other frame. The frames also need to be able to communicate with eachother and both have access to cordova libraries.
If someone has other ideas how to do this, i'm open for them.
Update :
I'm looking into cl.kunder.webviewhttps://github.com/kunder-lab/cl.kunder.webview plugin