Location permission issue iOS 11 and iOS 10 Location permission issue iOS 11 and iOS 10 swift swift

Location permission issue iOS 11 and iOS 10


I figured out the issue by creating a quick stand alone app that only asked for permissions, I was given an error log that stated the keys I was using were wrong.

I had NSLocationAlwaysAndWhenInUsageDescription instead of NSLocationAlwaysAndWhenInUseUsageDescription which is odd because from the docs it states that NSLocationAlwaysAndWhenInUsageDescription should be used. Switching to include the correct key fixed issue and now permissions works as expected for iOS 11 and 10.

Thanks for all the help.


In your info.plist file add this:

<key>NSLocationUsageDescription</key><string></string><key>NSLocationWhenInUseUsageDescription</key><string></string>

Now in your swift file, don't forget to add delegate: CLLocationManagerDelegate

In your viewDiDLoad(), add this:

locationManager = CLLocationManager()locationManager.delegate = selflocationManager.requestWhenInUseAuthorization()locationManager.desiredAccuracy = kCLLocationAccuracyBestlocationManager.startUpdatingLocation()locationManager.startMonitoringSignificantLocationChanges()// Here you can check whether you have allowed the permission or not.if CLLocationManager.locationServicesEnabled()    {        switch(CLLocationManager.authorizationStatus())        {        case .authorizedAlways, .authorizedWhenInUse:            print("Authorize.")            break        case .notDetermined:            print("Not determined.")            break        case .restricted:            print("Restricted.")            break        case .denied:            print("Denied.")        }    }


For both cases, customers and employees, you first need to call locationManager.requestWhenInUseAuthorization()

Then, only if they are employees, add a call tolocationManager.requestAlwaysAuthorization()

See https://developer.apple.com/documentation/corelocation/choosing_the_authorization_level_for_location_services/request_always_authorization

Overview To configure always authorization for location services, do the following: Add the NSLocationWhenInUseUsageDescription key and the NSLocationAlwaysAndWhenInUsageDescription key to your Info.plist file. (Xcode displays these keys as "Privacy - Location When In Use Usage Description" and "Privacy - Location Always and When In Use Usage Description" in the Info.plist editor.) If your app supports iOS 10 and earlier, add the NSLocationAlwaysUsageDescription key to your Info.plist file. (Xcode displays this key as "Privacy - Location Always Usage Description" in the Info.plist editor.) Create and configure your CLLocationManager object. Call the requestWhenInUseAuthorization() initially to enable your app's basic location support. Call the requestAlwaysAuthorization() method only when you use services that require that level of authorization.