Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Supporting iOS 11 location permissions while disallowing "when in use" on iOS 10

When using iOS 10 I need users to choose between never allowing location and always allowing locations, so I added the key NSLocationAlwaysUsageDescription in the Info.plist.

Now with the new iOS 11 release, I need to add the following two keys to get the location permission prompt - NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription.

When I try to remove the seemingly redundant NSLocationWhenInUseUsageDescription, it doesn't allow showing the location prompt on iOS 11

The problem is now my users on iOS 10 have a "when in use" option in their settings, which I don't want.

Is there any way to create a version which allows "never" and "always" for iOS 10 and allows all three options on iOS 11?

like image 731
Jonathan Oron Avatar asked Oct 29 '22 03:10

Jonathan Oron


1 Answers

You are required to include the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUsageDescription keys in your app's Info.plist file. (If your app supports iOS 10 and earlier, the NSLocationAlwaysUsageDescription key is also required.) If those keys are not present, authorization requests fail immediately.

https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services/request_always_authorization#see-also

like image 123
Ravi Avatar answered Nov 02 '22 23:11

Ravi