5
votes

I have a Cordova app and the first thing it does is check the users location when the app is started. The issue is that if this is the first time the user is starting the app (on iOS), the geolocation plugin does not wait for the user to say yes or no to the geo permissions dialog that iOS brings up.

Is there anyway I can get this plugin function to wait for the user to says allow or disallow for the geo permissions?

Plugin in question https://github.com/apache/cordova-plugin-geolocation

Example function call:

navigator.geolocation.getCurrentPosition(geolocationSuccess,geolocationError,geolocationOptions);

When I start the app up for the first time I get the iOS permissions prompt but I can see in the background that the function call has already dropped into the error function.

1
I have the same issue here and I don't know how to fix tried everything...Fernando Zamperin
@FernandoZamperin Did you manage to find a solution in the end?Aaron Fisher
Yeah I find a solution, I just ask for the permission on platform ready and then when I go to get the location it works perfectly! Try this plugin is easy to use github.com/dpa99c/…Fernando Zamperin

1 Answers

-1
votes

It needs modification in plist please follow below steps , below steps is supposed to be followed before adding ur platform in cordova :

Step 1:

add NSLocationWhenInUseUsageDescription to the .plist. Open /platforms/ios/{project}/{project}-Info.plist 

Step 2 : Add below

<key>NSLocationWhenInUseUsageDescription</key>
<string>[App Name] would like to access your location when running and displayed.</string>