Deviceready handler is not called ios phonegap 3.3.3

index.html

<script>
   function onDeviceReady() {
       alert("onDeviceReady");
       var options = {frequency: 500};
       watchId = navigator.accelerometer.watchAcceleration(onSuccess, onFailure, options);
    }
    document.addEventListener("deviceready", onDeviceReady, false);
</script>

Phone book. 3.3.3. The finished device handler is not called.

+4
source share
3 answers

remove app.initialize () from the script (which messed up the event handler)

-1
source

Make sure you include the phonegap.js (or cordova.js) script in your html. Otherwise, your code is fine. Try commenting on everything else except the warning in onDeviceReady () if the problem still persists.

Try posting your index.html asking if there are still problems.

+3
source

It is best to set up an event listener in the function after the document has finished loading. Try something like this:

<body onload="onLoad()">

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

or using jquery:

$(document).ready(function() {
    document.addEventListener("deviceready", onDeviceReady, false);
});
+2
source

All Articles