If you would like to trigger the “deviceready” event fires when Cordova is fully loaded for some plugin usage,
document.addEventListener("deviceready", callbackFunction, false);
you need to include cordova.js in your application.
<script type="text/javascript" src="cordova.js"></script>
OK, you are done.
If you facing some unknown error in console as below even you have whitelist plugin added, cordova.js included,
Uncaught Error: Module cordova-plugin-whitelist.whitelist does not exist. cordova.js:891 deviceready has not fired after 5 seconds. cordova.js:884 Channel not fired: onPluginsReady cordova.js:884 Channel not fired: onCordovaReady
then probably you include cordova.js wrongly as what I did (get from /platforms/android/assets/www/cordova.js)
<script src="asset/js/cordova.js"></script>
NOTE: You does not need to copy cordova.js from anywhere, just include as above mention will do, Cordova will figure out for u 🙂
When i put:
in my index.html it gives the error: Failed to load resource
location: file:///android_asset/www/asset/js/cordova.js
i’m using phonegap build version cli-5.2.0
can you help me?
thanks.
Do you have cordova.js generated at [YOUR_PROJECT]/platforms/android/assets/www/cordova.js when you first run “cordova platform add android” ?
If yes, probably you just need to include the script as below in your index.html.
I am facing same issue, I have included cordova.js still getting error (deviceready has not fired after 5 seconds.). I am using cordova 5.4.1 with adobe push plugin for push notification. Any solution so that i can check what is preventing deviceready function.
If you have included the cordova.js correctly, it should just work. Or can I suggest you to create separate clean cordova project without using any plugin to test out for deviceready event.
http://cordova.apache.org/docs/en/6.x/cordova/events/events.html
Can’t explain much as for now but I remember I have time when I try re-create my cordova project due to some issue, and it just works.
Good Luck !