deviceready not firing in cordova

There's no need to have the cordova.js inside your www/js/ folder because that file is copied from another location to platforms/ios/platform_www (i.e. by running: cordova build ios) at the same level that the index.html file, so in order to have a proper configuration, the next statement:

<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script>

must be changed to:

<script type="text/javascript" charset="utf-8" src="cordova.js"></script>

I had the same problem, my solution was to add :

<script type="text/javascript" src="cordova.js"></script>

in the HTML file and everything worked perfectly


I had this same issue, but in my case cordova.js was already properly included.

Eventually what worked for me was a simple remove and add of the ios platform:

cordova platform remove ios
cordova platform add ios

It had been quite a while since I had completely re-built the ios platform and other major changes had taken place during that time (Cordova upgrade, XCode upgrade, etc). It's possible that my config.xml or existing ios build was somehow incompliant with the latest Cordova requirements.


deviceready event is essential to any application. It signals that Cordova's device APIs have loaded and are ready to access.

Update

So I got "deviceready" to work by removing the onload="onLoad()" from the body and replacing this:

function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

with just this:

document.addEventListener("deviceready", onDeviceReady, false);