Angular & Ionic, $http.get not working in IOS8.3

I have a service on my Ionic application that work fine in an Iphone4 with IOS7 but now I updated to IOS8.3 and don’t work…

The problem is that no result (success or error) is returned.

This issue is only on real device with IOS8.3 (on Xcode simulator works fine). And also still working fine on old Iphone4 with IOS7.1.2

var appServices = angular.module('app.services', []);
appServices.factory('GetJsonData', function ($http, $q) {
    return {
        query: function () {
            var url = 'http://dummy-url-to-file.json';
            var data = $http.get(url);
            var deferred = $q.defer();
            deferred.resolve(data);
            return deferred.promise;
        }
    }
});

I also test with a very simple code in a controller, and neither work

$http.get('http://dummy-url-to-file.json').then(function(data) {
    alert("ok!");
})

I have installed the cordova-white-list plugin, and is well configured… so the code works fine until the last ios8.3 Apple update

The http://dummy-url-to-file.json is the real URI?

No! I put this dummy uri only for the example code…
In the app I have a real url that return a json file well formated from a restfull api

Ok, if you can, check the server log to see if the app does the request. Then check if the server return the correct content type.

I check the requests…

On IPhone4 with IOS7.1.2 the request is done fine. This is the log:

37.133.214.122 - - [15/Jun/2015:18:09:40 +0200] "GET /munav/interface.json HTTP/1.1" 200 8147 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 7_1_2 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D257 (374711760)"

On the Xcode simulator with Iphone5s IOS8.3 also make the request fine…

37.133.214.122 - - [15/Jun/2015:18:16:27 +0200] "GET /munav/interface.json HTTP/1.1" 200 8147 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12F69 (140445320620576)"

But on a real Iphone5 with IOS8.3 the request is not called to the server, and not log is created… :frowning:

Your promise function has some problems.
You should do the following.

appServices.factory('GetJsonData', function ($http, $q) {
    return {
        query: function () {
            var url = 'http://dummy-url-to-file.json';
            var deferred = $q.defer();
            var data = $http.get(url).success(function(data){
               deferred.resolve(data);
            }).error(function(err){
               defferred.reject(err)
            });
            return deferred.promise;
        }
    }
});

The promise should be wrapped in the http callback.
Hope this helps.

Thanks but I checked the code, and still doesn’t work …

I think it is a configuration problem of specific privileges for ios8.3 because the call to the server is not made, and the same code works fine in ios7 … :frowning:

I wrote an API a while back that for security it locked users out if their user agent wasn’t consistent. SO it’s possible that if they are utilizing that user agent string it’s blocking the request. I would just check that as the rest of this looks normal and should work.

Have you tried replicating this on an entirely blank project? Another possibility is that if a plugin is broken in your application and you don’t handle that correctly in the Javascript that it could cause issues elsewhere in your code that is tied to that plugin.

I create a new blank app and I put the $http.get on the $ionicPlatform.ready, and the request works fine on Iphone4 with IOS7 but still doesn’t working on Iphone5 with IOS8.3… :frowning:

This is all the code of this app:

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

.run(function($ionicPlatform, $http) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }    
        $http.get('http://munav.tfinteractiva.info/ws/8c07e8669dac8ff95136cecce7a6cfc9/action/idiomas/').then(function(data) {
        alert("ok");
    })
                       
  });
})

So I’m a bit confused as to why you did this in a run? Normally and kind of data retrieval would be done in a service.
Either way, I tested this codepen out on a iphone5 running ios8 and it works fine for me.

  .factory('Data', function($http) {
    // create an empty array
    var people = [];
    return {
      all: function() {
        ///Lets fetch data
        return $http.get('http://api.randomuser.me/?results=10')
          .then(function(responce) {
            people = responce.data.results;
            return people;
          });
      }
    };
  })

Is there anyway you could provide a codepen or demo of what you have?