Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova geoLocation plugin in iOS not working fine

Now I am using cordova application app for getting current latitude and longitude so I have used cordova geolocation plugin for both iOS and android.

This plugin I have installed in CLI

cordova plugin add org.apache.cordova.geolocation 

and I have used the same codes used in https://cordova.apache.org/docs/en/3.0.0/cordova_geolocation_geolocation.md.html

But its worked fine in android and iOS simulator (custom location) but in my iPad and iPhone its don't work ...I don't know why please tell anyone why some times its showing error like code:2, message:

The operation couldn’t be completed. (kCLErrorDomain error 0.) & code:3 error....

like image 988
Hari Narayanan Avatar asked Jul 13 '15 09:07

Hari Narayanan


1 Answers

If you add the Geolocation plugin (but no 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

like image 91
9to5ios Avatar answered Nov 02 '22 14:11

9to5ios