5

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Aaron Fisher
  • 645
  • 3
  • 8
  • 23

1 Answers1

-1

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>
KOTIOS
  • 11,177
  • 3
  • 39
  • 66
  • also chk this : http://stackoverflow.com/questions/28891339/fix-cordova-geolocation-ask-for-location-message/30742592 – KOTIOS Apr 06 '16 at 09:01
  • Ah, perfect! I thought it would be a Javascript solution or something, not something in the actual build. – Aaron Fisher Apr 06 '16 at 09:20
  • 1
    The issue is now, that just seems to be a custom message. It still executes the timer on the timeout behind the message and will then the error after the timer expires. – Aaron Fisher Apr 06 '16 at 09:26