The deviceready isn't firing correctly (at least in iOS) for my cordova project. I have searched for hours and still cannot figure this out. Am I doing something incorrectly? The path to js/cordova.js exists as well:
<html>
<head>
<title>Geolocation</title>
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi, user-scalable=no" />
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="css/app.css">
<script type="text/javascript">
// Fastclick
if ('addEventListener' in document) {
document.addEventListener('DOMContentLoaded', function() {
FastClick.attach(document.body);
}, false);
}
</script>
<script type="text/javascript" charset="utf-8" src="js/cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for device API libraries to load
//
function onLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
// device APIs are available
//
function onDeviceReady() {
alert("ready");
// Now safe to use device APIs
}
</script>
</head>
<body onload="onLoad()">
I'm not sure what I'm missing as I'm not getting any errors if I inspect in Chrome
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With