0
votes

Currently building an app using Phonegap 3.5 (problem also occurred in 3.3) with Ionic for the front-end interface.

When running on my iPhone, the app sometimes works fine and sometimes doesn't. I can't figure out when it will do which. When it fails, Weinre gets the message:

deviceready has not fired after 5 seconds.

Channel not fired: onCordovaReady

Again, it's inconsistent. Sometimes it fires, sometimes it doesn't. I build an ad-hoc version of the app and gave it to another developer; for him, it consistently fails to fire the event.

I'm not even sure how to go about debugging the issue. Suggestions?

1
Turns out I hadn't properly updated my platform cordova.js. Used phonegap platform update ios to update to 3.5 and the problem appears to have gone away.thechrisroberts

1 Answers

1
votes

Have you seen this?

http://forum.ionicframework.com/t/when-are-the-angular-controllers-loaded/239

There isn't necessarily a connection between controller load time and deviceready firing. That event comes from the Cordova internals, and if you set the listener too late, the event will have already fired and you'll miss it.

To deal with this, we've given you the Platform service, which you can use to always call a function when the device is ready (or after if it's already been loaded):

controller('MyCtrl', function($scope, Platform) {
  Platform.ready(function() {
    // Platform stuff here.
  });
});

Later post says:

controller('MyCtrl', function($scope, $ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Platform stuff here.
  });
});

Which makes more sense within the angular framework