Raildex
Raildex

Reputation: 4765

requestLocation() does not ask for permission even though "Ask next time" is ticked

I have a variable var locationManager: CLLocationManager.

During the runtime of the app, I want to ask for a one-time location with locationManager.requestLocation().

However when I do so, the delegate almost immediately informs me with locationManager(manager:didFailWithError:) Even though in my security settings, Location is set as "Ask next Time".

When I set the setting to "Always", i receive a proper location update, but I don't want the user to explicitly activate them in the settings. How can I make my App ask for permission?

Edit: Usage Descriptions are properly set.

Upvotes: 0

Views: 513

Answers (1)

Paulw11
Paulw11

Reputation: 115002

requestlocation gets a one-time location and avoids the energy impact of continuous location updates where only a single location update is required, but it does not prompt the user for location permission.

If your authorisation state is .notDetermined you need to call requestWhenInUseAuthorization and receive an authorisation callback with a positive result before you can call requestLocation.

Upvotes: 1

Related Questions