A simple tip to use navigator.geolocation.getCurrentPosition(success, error, options) with iOS8.

I made some cordova apps on my old iDevices (running iOS 7 and iOS 6), they make use of the core location to localize the device itself.

I had some troubles when I moved my apps on iOS 8, since the devices didn’t ask me to activate the core location. Here you are the solution for this silly problem:

When you have written your javascript code that makes use of the core location, build your application running the following command:

$ cordova build ios

then open the iOS project:

$ open  platforms/ios/<your_project>.xcodeproj/

and from Xcode right-click on the <your_project>-Info.plist and “Open As”->”Source Code”

After the first <dict> tag, add the following lines:

<key>NSLocationWhenInUseUsageDescription</key>

<string>App want to use your location</string>

<key>NSLocationAlwaysUsageDescription</key>

<string>App want to use your location</string>

You can personalize the two strings has you want, but it seems they are not used!!!!

My iPad shows the following alert:

Core Location Permission

Anyone knows as to solve this issue? I would like to have the string “HelloWorld.app Would Like to Use Your Current Location“, instead of the above one…

Now you have only to run your application on your iOS 8 device.

Gg1