kris
kris

Reputation: 12580

Cordova iOS deviceready never fires

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

Answers (1)

kris
kris

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:

What seemed to solve it

  1. Remove all plugins and re-add them

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 )

What may have also helped

  1. I updated to the latest Xcode

  2. Update cordova (and cordova-ios) to the latest version

sudo npm install -g cordova
cordova platform update ios@latest

  1. Add and remove ios platform

cordova platform rm ios
cordova platform add ios

Upvotes: 1

Related Questions