When my app launches the map view, I request the iOS8 "When In Use" location permission. Assume user grants that.
I would like to request the Always permission only when user opts-in to my geofencing feature. But calling CLLocationManager.requestAlwaysAuthorization has no effect because the current authorization status is no longer kCLAuthorizationStatusNotDetermined.
How would one go about requesting the Always permission AFTER user has granted When In Use permission? I would think this is a common use case because apps should avoid asking for the Always permission unless needed.
You are right, calling
requestAlwaysAuthorization
will not do anything if the user already granted 'when in use' permission. A workaround I used was to link the user to the settings screen and let them turn on the 'Always' setting themselves. Here are the steps to do that:Create a new key in your
app-Info.plist
calledNSLocationAlwaysUsageDescription
and enter some reasons as to why you need to request the always permission in the value field.Link your user to your app's settings screen (more info here)
Once the user taps your link they will see this:
and when they click on
Location
, they will be able to see bothWhile Using the App
andAlways
settings to choose from:locationManager:didChangeAuthorizationStatus:
I don't know about objective-c, but it works fine for me in swift and iOS 8.4. Make sure you provide both keys in your info.plist
Then just call
And make sure locationManager is an instance variable! A local variable will be ignored for some strange reason. Apple Documentation