Location Services not working in iOS 11
It would appear that apple have added yet another privacy feature. The user is now able to override our requestAlwaysAuthorization
and downgrade it to requestWhenInUseAuthorization
- Which means as a developer we now have to supply both descriptions in the Info.plist
I found that they have added a new key NSLocationAlwaysAndWhenInUseUsageDescription
/*
* Either the NSLocationAlwaysAndWhenInUseUsageDescription key or both the
* NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription
* keys must be specified in your Info.plist; otherwise, this method will do
* nothing, as your app will be assumed not to support Always authorization.
*/
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:
This app has attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain both NSLocationAlwaysAndWhenInUseUsageDescription and NSLocationWhenInUseUsageDescription keys with string values explaining to the user how the app uses this data
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 keys NSLocationWhenInUseUsageDescription
, locations services will start to work again.
iOS 11 updating Location Services from While Using to Always
This question was solved with a symbolic breakpoint over all CoreLocation lib.
How?
1 - put a breakpoint on the first line of didFinishLaunchingWithOptions
2 - start your app
3 - on console panel, insert this command to break in every method of CoreLocation lib
lldb: break set -r CoreLocation
4 - resume your app
Now the debug will stop at every function invoked from CoreLocation lib
The problem was that a dependency was checking for background modes without my realizing it, so this was triggering the alert.
iOS 11 Location Permission in
For iOS 11, there's a new key NSLocationAlwaysAndWhenInUseUsageDescription
. Add this key to Info.plist
.
Can't get background location update on iOS 11
You could be missing two things:
- Set
allowsBackgroundLocationUpdates
toYES
on theCLLocationManager
object. See Apple Documentation - Enable "location" as a background mode in your Info.plist file. See Apple Documentation
Location Access Request in iOS 11
It is not optional anymore.
Since iOS 11 has been released, if your application requests the location to be always on (locationManager.requestAlwaysAuthorization()
), the users will automatically be given all three options.
Unlike in previous iOS versions, all options have to be displayed to the user. That leads to: you have to add a key for both options.
Adapted from Apple's Article - Requesting Always Authorization:
You are required to include the
NSLocationWhenInUseUsageDescription
andNSLocationAlwaysAndWhenInUseUsageDescription
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.
Reference: What's New in Location Technologies Video Session.
Related Topics
Shift Elements in Array by Index
Xcode - Ld: Library Not Found for -Lpods
Wrong Color in Interface Builder
Alternative to Dtsendsignalflag to Identify Key Events in Instruments
Inconsistent Unicode Emoji Glyphs/Symbols
iOS Keeping Old Launch Screen and App Icon After Update
Uploading Image with Afnetworking 2.0
How to Open File and Append a String in It, Swift
How to Test If a String Is Empty in Objective-C
Prevent Segue in Prepareforsegue Method
Crashlytics: "We'Re Missing a Dsym to Process Crashes"
How to Recognize Which Pin Was Tapped
Core Data Background Context Best Practice
Uilabel with Text of Two Different Colors
What's the Best Way to Find the User's Documents Directory on an Iphone
Foreign Key Relationship Mapping with Restkit