Geolocation not working on iOS 8

  • 37
  • Problem
  • Updated 4 years ago
  • Solved
Im testing our PG app for the coming iOS 8 release and I can't get the geolocation plugin to get my position. Everything works fine under iOS 7. Im currently using iOS 8 Beta 5 and the latest cordova and geolocation plugin builds.
Photo of Karl Söderberg

Karl Söderberg

  • 1 Post
  • 0 Reply Likes

Posted 6 years ago

  • 37
Photo of ryan

ryan, Developer

  • 1538 Posts
  • 132 Reply Likes
Official Response
OK, I just tested things out using PhoneGap 3.6.3 and Geolocation 0.3.10 on iOS 8.

If you add the Geolocation plugin (but no <config-file> changes) to your config.xml, you will find the following in your compiled app's Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string></string>

The result of which is that on a geolocation call, the user is prompted with

Allow "App Name" to access your location while you use the app?


If in addition to the plugin you add the following to your config.xml:

<gap:config-file platform="ios" parent="NSLocationAlwaysUsageDescription" overwrite="true">
<string>WE RE LIKE TOTALLY TRACKING YOU OMG</string>
</gap:config-file>

you will find the following in your compiled app's Info.plist:

<key>NSLocationAlwaysUsageDescription</key>
<string>WE RE LIKE TOTALLY TRACKING YOU OMG</string>


and the result will be that on a geolocation call, the user is prompted with

Allow "App Name" to access your location even when you are not using the app? WE RE LIKE TOTALLY TRACKING YOU OMG


After clicking allow in both scenarios, geolocation calls were successful. If you are unable to get any of this working, please post your App ID and I will try to have a look.

For references sake, here is the default Plist settings created by adding the plugin:
https://github.com/apache/cordova-plu...
And here is the code which determines whether to requestAlwaysAuthorization or requestWhenInUseAuthorization:
https://github.com/apache/cordova-plu...