Q: Why does the JavaScript Promise not work on Android 4.4 using the Ionic Framework? i am using ionic + firebase to make a chatting application. When a message comes to the phone, it comes with uid, i need to fetch username with that uid to show user the message (username:messagetext). But fetching username from firebase directly takes time(and bandwith). So i need to cache these uid:username pairs. System i wrote works on website and android emulator. But when i try to install it on my android phone it does not work. Here is the code.
  var uNameCache = {};
  function getUsername(uid) {
    toastr.info("Fetching username for "+uid);
    return new Promise(function(resolve, reject) {
      toastr.info("Trying to fetch with a promise");//this is not showing on an actual android phone
      if(uNameCache[uid]){
        //get from cache
        toastr.info("get from cache");
        resolve(uNameCache[uid]);
      }else{
        //get from firebase
        toastr.info("get from firebase");
        firebase.database().ref('users').child(uid).once('value').then(function(snapshot) {
          var username = snapshot.val().username;
          uNameCache[uid] = username;
          resolve(username);
        });
      }
      //resolve("High_Admin");      
      // reject ("Error!");
    });
  };

and here is the code that uses this
firebase.database().ref('channel_messages').child(channelid).on('child_added',function(snapshot){
    var msg = snapshot.val();
    toastr.info("message get");
    getUsername(msg.uid).then(function(username){
      toastr.info("username fetched!");
      msg.username = username;
      $scope.messages.push(msg);
      //todo if scrollplace down scroll down, else dont touch player is reading old messages.
      $ionicScrollDelegate.$getByHandle('mainScroll').scrollBottom();
      $scope.$apply();
    });
  });

edit: I am still not sure why this happened but i find a shortcut by just deleting promise and dealing it on firebase event.

A: I think that this may be due to the fact that older versions of Android do not supports JavaScript Promises. You can check such things on this website.
The big difference is that the Angular Promise is called $q, but other than that you won't notice that many differences. You can find a lot more information about it in the documentation.
In your code, you need to inject $q as a dependency and change:
return new Promise(function(resolve, reject) {

To this:
return $q(function(resolve, reject) {

