Reputation: 12580
I've been developing Cordova apps for a number of years now, and often I come across the problem where the "deviceready" event simply does not fire in iOS.
(This is not the cordova.js
file missing, which seems to be the only answer I'm finding on SO).
Currently I'm using Cordova v6.3.1, though I've had this same issue on many earlier versions.
Surely others face this issue - I'm going to try and solve it now and will post the answer here.
Sample index.html
code:
<html>
<body>
<script src="cordova.js"></script>
<script>
document.addEventListener("deviceready",
function() { alert('device ready fired!'); }, false);
</script>
</body>
</html>
Upvotes: 4
Views: 1940
Reputation: 12580
This may have been caused by the changes by iOS, making the push plugin I was using stop working.
I've done many things, they may have all helped, I'll list them all:
cordova plugin ls (see all plugins and make a note of them)
cordova plugin rm plugin-name (for each one)
cordova plugin add plugin-name (add 'em all back in )
I updated to the latest Xcode
Update cordova (and cordova-ios) to the latest version
sudo npm install -g cordova
cordova platform update ios@latest
cordova platform rm ios
cordova platform add ios
Upvotes: 1