$cordovaGeolocation.getCurrentPosition always returning “Position retrieval timed out.” in ios

Hi,

I’m using Cordova 4.3.1,with cordova-plugin-geolocation 1.0.1, in ionic 1.7.8. (All searches with the following error point to older versions, and say this one should work fine)

When I use

    $cordovaGeolocation.getCurrentPosition(posOptions).then(function (data) {
  deferred.resolve({latitude : data.coords.latitude,longitude : data.coords.longitude});
}, function (err) {
  deferred.resolve({latitude : null,longitude : null});
      console.log(err);
  });

I always get “Position retrieval timed out.”

The application works fine on Android.

And retrying the same on ios i found out that :

The application is not asking me permission to get my location

If I try to debug it on ios, CDVLocation.m is not being accessed

The location icon in the top bar is not displaying.

Is there anything wrong in my configuration ?

Anything i should add to ios or config.xml ?

Thanks,

Hi,

Several things to check

  • Did you do command ionic build ios yet? This will copy js and m files from plugin folder to your xCode project plugins folder.
  • If they are properly installed, you can take a look at the source of ngCordova and call the plugin directly without going through Angular. For example: window.cordova.plugins.geolocation.

Hope these helps!

I found the problem, The issue was that i had to downgrade cordova because of an issue with whitelisting, and was still using the new plugin.

After removing the plugin and installing again the old one, it worked.

Thank you

I’m having an issue with geolocation timing out too - what version of cordova, whitelist plugin and geolocation plugin are you running now?

Even with geolocation working - we still get that error too. All the time. Still not been able to track down why. I assume there is just a thread that goes off on its own from the plugin at each start up.

I finally soved it by removing and adding back the plugin. this issue happened with more than one plugin. It seems updating cordova or ioninc in the middle of a project is a bad idea :smiley: