I just rebuilt my app with the iOS 11 SDK in an attempt to remove the blue banner
that is now always appearing. I thought - "Brilliant, that worked", only to discover that location services are now not working at all.
The application used to work with iOS 10 - Has anybody heard anything?
It would appear that apple have added yet another privacy feature. The user is now able to override our
requestAlwaysAuthorization
and downgrade it torequestWhenInUseAuthorization
- Which means as a developer we now have to supply both descriptions in theInfo.plist
I found that they have added a new key
NSLocationAlwaysAndWhenInUseUsageDescription
However, upon using this new key - the location service still didn't work, upon further searching I found this gem mixed in with all the extra debugging information:
Which directly contradicts the the comment that I found in the updated
CLLocationManager.h
file. So I've created a radar.Good news, if you follow the advice of the debugging console, IE. add both the new key
NSLocationAlwaysAndWhenInUseUsageDescription
and one of the old keysNSLocationWhenInUseUsageDescription
, locations services will start to work again.Working in Swift 4.0.3
Swift : 3 i have faced the same issue. i was totally screwed up finding the solution. here is how i fixed the issue.
step-1 : Project file > Capabilities > background modes > select Location Update
step-2 : Add NSLocationWhenInUseUsageDescription , NSLocationAlwaysAndWhenInUseUsageDescription keys to Info.plist
step-3 :
Just to add the steps on fixing this:
2 ways to do it:
A) The easy way: Select your Info.plist file, add the properties, note that they start with PRIVCY instead of LOCATION... therefore, the exact names of these variables starts with "Privacy - Location ... " etc, add each here, and describe how the user would be seeing this on the warning.
B) The hard / interesting / programatic way (I like this way more):
Right click on your Info.plist for your app, and then select "View source code", you should see it all in XML,
Follow the other ...... format, and add these properties as follows:
Save, and then right-click on the info.plist file, and then select Property list, this should view the file back into the default view.
EDIT:
Another member asked for code, here it is:
1) On your .H file, add:
2) On your .M file add under ViewDidAppear() function:
This what works fine for me, hopefully the code would work for you too.
Regards
Heider
working under iOS11 i discovered, that Info.plist needs al least NSLocationAlwaysAndWhenInUseUsageDescription in Info.plist:
Strange enough when your app is multilingual the localized versions of your strings need all three keys mentioned in this post else
requestAlwaysAuthorization()
andlocationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
will fail silently.Shot showing german translation as example:
Hope this saves you time when stumbling upon.
Better safe than sorry .. In iOS 11 : Add the below and you are good.