# $http.get doesn't work when live-testing on iOS

**URL:** <https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693>\
**Category:** ionic-v1\
**Created:** [April 7, 2016, 1:06pm UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693 "2016-04-07T13:06:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grayda](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grayda/32/97013_2.png) [@Grayda](https://forum.ionicframework.com/u/Grayda)\
**Post date:** [April 7, 2016, 1:06pm UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693/1 "2016-04-07T13:06:15Z")

</div>

My app works great on Android and in the browser, but on my iPhone 4s running iOS 9.2.1, my initial $http.get doesn’t complete, nor does it throw an error.

I’ve read about needing to install the whitelist plugin, which I did. I also installed an npm package ([https://www.npmjs.com/package/cordova-plugin-transport-security](https://www.npmjs.com/package/cordova-plugin-transport-security)) which added the required lines into AppName-info.plist just fine, but no matter what I do, my $http.get simply won’t run, even though the website in question is **https**.

Full disclosure: Tonight is the second time I’ve ever touched Xcode, my first time being about five years prior to fiddle with Objective-C

Here’s the code in question that doesn’t run:

```
.factory('aceFactory', ["$http", "$q", function($http, $q, $rootScope) {
  return {
    service: "https://api.example.com/v1/?type=all",
    loadData: function(lat, long) {
      var deferred = $q.defer()
      $http.get(this.service + "&source=app&lat=" + lat + "&long=" + long + "&tz=" + new Date().getTimezoneOffset(), {
        timeout: 15000
      }).then(function(data) {
        deferred.resolve(data.data)
      }, function(err) {
        alert(err.data.message)
      });
      return deferred.promise
    }
  }
}])

```

The code code doesn’t even time out after 15 seconds, it just sits there with the spinner (that is shown before the $http.get call) and never progresses, even after half an hour of waiting.

Anyone come across this issue yet?

---

<div class="post-metadata">

**Author:** ![lunixrules](https://avatars.discourse-cdn.com/v4/letter/l/da6949/32.png) [@lunixrules](https://forum.ionicframework.com/u/lunixrules)\
**Post date:** [April 7, 2016, 3:32pm UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693/2 "2016-04-07T15:32:31Z")

</div>

> [@Grayda](#):
>
> }  
> }])

> <https://gist.github.com/mlynch/284699d676fe9ed0abfa>

---

<div class="post-metadata">

**Author:** ![Grayda](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grayda/32/97013_2.png) [@Grayda](https://forum.ionicframework.com/u/Grayda)\
**Post date:** [April 7, 2016, 9:37pm UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693/3 "2016-04-07T21:37:28Z")

</div>

> [@Grayda](#):
>
> I also installed an npm package ([cordova-plugin-transport-security - npm](https://www.npmjs.com/package/cordova-plugin-transport-security)) which added the required lines into AppName-info.plist just fine

So my plist file is fine (contains the same lines as what is shown in the gist you posted), but my $http.get still won’t complete.

---

<div class="post-metadata">

**Author:** ![Grayda](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grayda/32/97013_2.png) [@Grayda](https://forum.ionicframework.com/u/Grayda)\
**Post date:** [April 8, 2016, 10:50am UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693/4 "2016-04-08T10:50:11Z")

</div>

Right, so I’ve made some progress on this. I discovered that if I manually call the function that does the $http.get call (it currently runs $ionicPlatform.ready), then my app actually does load. The $http.get call simply wasn’t firing on `ready()`, but runs just fine when I run it myself

For reference, I set Mobile Safari to allow remote debugging, then went into Safari, turned on developer mode, then opened the web inspector for the iPhone, on my Mac. Then I manually ran: `angular.element($0).scope().loadData()` which actually tried to load my data, then succeeded

But any explanations as to why I have to do that and why $ionicPlatform.ready doesn’t work as expected, would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![Grayda](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/grayda/32/97013_2.png) [@Grayda](https://forum.ionicframework.com/u/Grayda)\
**Post date:** [April 8, 2016, 2:23pm UTC](https://forum.ionicframework.com/t/http-get-doesnt-work-when-live-testing-on-ios/48693/5 "2016-04-08T14:23:23Z")

</div>

After hours of fiddling, working with remote debugging in Safari and tons of console.log calls, plus barking up several wrong trees, I figured out that my geolocation calls were failing and not raising an error. I installed the cordova geolocation plugin (instead of using the browser implementation) and immediately got asked if I wanted to allow the app to use my location.

Now my data loads perfectly every time.
