I am using Cordova to build mobile apps but for some reason device ready not fired.
Here are some of the codes.
<script type="text/javascript" src="cordova.js"></script>
<script src="./js/jquery-2.1.3.min.js"></script>
<script src="./js/angular.min.js"></script>
<script type="text/javascript">
document.addEventListener("deviceready", function(){
alert("123");
},true);
function plays() {
window.HeadsetDetection.detect(function(detected) {
window.plugins.insomnia.keepAwake()
cordova.plugins.tonegenerator.play(650)
})
document.addEventListener('deviceready', function() {
window.HeadsetDetection.registerRemoteEvents(function(status) {
switch (status) {
case 'headsetAdded':
window.plugins.insomnia.keepAwake()
cordova.plugins.tonegenerator.play(340)
break;
case 'headsetRemoved':
alert('Please connect to Headset/Earpiece then play.');
break;
};
});
}, true);
}
<a class="btn btn-home" onclick="plays()"><i class="icon ion-ios-play"></i> Play</a><br><br>
When I click on Play button sound is playing. As you can see there is some alert box on device ready. Those alert are not firing.
Any advice what am I doing wrong here?
Thanks