Search code examples
cordovacordova-2.0.0

deviceready event breaks after upgrading to cordova 2.2.0


In IOS after upgrading from cordova 2.1.0 to 2.2.0 the deviceready event doesn't fire anymore. Anybody else having this problem?

var onDeviceReady = function() {
    device_ready = true;
    alert('dev ready');
    initApp();
};

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

Anybody else have this problem?


Solution

  • Try changing the position of the code. I had the similar issue and changing the position of the code and also calling the .addEventListener, body onLoad event solved the issue.

    function onLoad() {
          document.addEventListener("deviceready", onDeviceReady, false);
    }
    
    var onDeviceReady = function() {
        device_ready = true;
        alert('dev ready');
        initApp();
    };
    
    ....
    
    <body onload="onLoad()">
    

    Also try to check you plugins.xml and config.xml, it is possible that there are some deprecated properties in the new version.

    Would it be possible for you to post the logs as well?