Geolocation will timeout before prompt on iOS

Hi guys :sunglasses:

I’ve been using Ionic for a while and know my ways around it but I recently bumped into an issue which I cannot solve.

All I am trying to do is get the user’s location when the app loads. For this I am using a controller that on the deviceready event listener will use NgCordova’s geolocation to get the users location.

My code works perfectly most of the time. The only times it WONT WORK is when a user launch’s the app and gets the “My App would like to use your location prompt” AND waits for 30 seconds (the timeout time). If a user waits for 30 seconds before allowing the app to use the location the location code will timeout. This is the error I get (this is all done on iOs):


PositionError {
message: “Timeout expired”,
code: 3,

My Code

.controller('NearbyCtrl', function($cordovaGeolocation) {

  document.addEventListener("deviceready", function(){

    var posOptions = {timeout: 30000, enableHighAccuracy: false};

      .then(function (position) {
        var lat  = position.coords.latitude;
        var long = position.coords.longitude;
        alert(lat + ", " + long);
      }, function(error) {
        alert('code: '    + error.code    + '\n' +
        'message: ' + error.message + '\n');

  }, false);


I have tried also use enableHighAccuracy: true but get the same results.

Any ideas would be appreciated! Thanks

@alexranc, have you resolved this? I am having a similar issue with iOS 10. Thanks.

@alexranc, I’ve got a similar problem than you. Despite it has passed some time since your original post, this may help others. If you’re having trouble making Cordova GeoLocation plugin to work on iOS, try this.