javascriptlinuxcordovaionic-frameworkready

$ionicDevice.ready() does not fire when building on linux


I've been struggling wit this few days now and just can't work it out.

This is my .run part in app.js file located in the www/js/ folder:

angular.module('starter', ['ionic', 'starter.controllers', 'ngCordova'])

.run(function($rootScope, $state, $ionicPlatform, $cordovaDevice) {
  $ionicPlatform.ready(function(){

    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }

    alert( 'Platform ready!' );
    $rootScope.uuid = $cordovaDevice.getUUID();
    //$rootScope.$apply();
    alert( 'Uuid: ' + $rootScope.uuid );
  });
})

And this is my controller which takes the $rootScope.uuid and passes it to local $scope.uuid variable:

app.controller('RoomlistsCtrl', function($rootScope, $scope, $ionicModal, $sailsBind) {
  $scope.uuid = $rootScope.uuid;
});

which is used in form for adding new item on the list on server:

<input ng-model="newItem.uuid" type="hidden" value="{{ uuid }}">

The thing is, when i ionic build android on windows (on my work PC) everything works fine, i get the alert with uuid after the device is ready, BUT on my home PC (which runs Elementary 0.3 Freya) when i ionic build android the build goes well, everything seems to be ok but i dont get the alert after i run the app on android phone (4.2).

I have device plugin installed, this is output:

amotio@potato:~/git/my_project/mobile$ ionic plugin add org.apache.cordova.device
running cordova plugin add org.apache.cordova.device
Fetching plugin "org.apache.cordova.device" via plugin registry
Plugin "org.apache.cordova.device" already installed on android.
Saving plugin to package.json file

I've included dependency in .run function and as far as i know, everything is as supposed to be.

Does anyone know what can be the case here? I've trying to solve this for past 2 days, intensively, I've read almost everything from documentation (which still uses the old way of calling ionic.Platform.ready() - which i also tried without success, I've included cordova.js file just before </body> tag as someone mentioned in other stack question.

I'm glad for any help or lead that'll reveal what could be wrong, thank you.


Solution

  • have you tried to setup the alert JUST after tje device ready instruction ?

    Probably the issue is linked the the command above your first alert

    if (window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if (window.StatusBar) {
      // org.apache.cordova.statusbar required
      StatusBar.styleDefault();
    }
    

    Print out each value of window.cordova / window.cordova.plugins.Keyboard & window.StatusBar cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true); or StatusBar.styleDefault(); is probably sending that issue