Cordon geolocation plugin in iOS not working fine

Now I use the cordova app to get the current latitude and longitude , so I used the cordova geolocation plugin for iOS and Android.

This plugin that I installed in the CLI

 cordova plugin add org.apache.cordova.geolocation 

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

But it worked perfectly in the android and iOS simulator (user location), but it doesn’t work on my iPad and iPhone ... I don’t know why, please tell someone why some of his errors show code: 2, message:

The operation could not be completed. (error kCLErrorDomain 0.) and code: error 3.

+5
source share
1 answer

If you add the Geolocation plugin (but without changes) to your config.xml, you will find the following in your compiled Info.plist application:

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

The result is that when you call the geolocation, the user is prompted

Allow the "app name" to access your location while using 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 Info.plist application:

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

and the result will be that when you call the geolocation, the user is prompted

Allow the "application name" to access your location even if you are not using the application? WE WILL MAKE A FULL TRACKING FOR YOU OMG

After clicking the allow button in both scenarios, geolocation calls were successful

+3
source

All Articles