Core Location in iOS 8

Shame on you, Apple! You left out some very critical documentation in the Core Location programming guide and CLLocationManager class references! I bet there are frustrated developers all over.

nn

Apple changed how permissions for location services are requested in apps through Core Location. Its a fairly simple change (a new function and two new Info.plist keys), but location services will not work in your app without it!

nn

Call this function from your CLLocationManager for apps using location services when in the foreground:

nn

requestWhenInUseAuthorization()

nn

Or call this function from your CLLocationManager for apps using location services at all times (even in the background):

nn

requestAlwaysAuthorization()

nn

Then add the following keys to your Info.plist:

nn

<code><key>NSLocationUsageDescription</key> <string>My App would pretty please like to use your GPS.</string>nn<key>NSLocationWhenInUseUsageDescription</key> <string>My App would pretty please like to use your GPS.</string>n</code>n

nn

Click the Chris Hulbert’s page for more details.

Leave a Reply

Your email address will not be published. Required fields are marked *