If you have built your application using the iOS 7 SDK before, and now you are using the iOS 8 SDK, chances are you need to do some code changes to correctly support iOS 8. One of them is the use of Location Services, or the CLLocationManager
class. If you do not perform the needed changes, you will see that your app does not try to retrieve GPS or location information. If your app is newly installed, the location permission dialog will not be displayed.
As a summary, you will need to apply the following code changes to CLLocationManager
in iOS 8:
- Add the following keys to your
Info.plist
file depending on your needs, and give them a string value. The string value explains why you need to get the user’s location information, so you should give it something like “Location information is needed in order to provide you with better user experience.” This string will be displayed to the user when the location permission dialog is displayed.
12NSLocationWhenInUseUsageDescriptionNSLocationAlwaysUsageDescription - If your app is localized, you can also localize the above strings by adding entries in your
InfoPlist.strings
file.
12/* Localized versions of Info.plist keys */"NSLocationWhenInUseUsageDescription" = "Location information is needed in order to provide you with better user experience."; - Before calling
CLLocationManager
‘sstartUpdatingLocation
, call one of the following methods, depending on your needs.
12[self.locationManager requestWhenInUseAuthorization][self.locationManager requestAlwaysAuthorization]
123if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {[self.locationManager requestWhenInUseAuthorization];} - If you have been using the
kCLAuthorizationStatusAuthorized
in your code before, you may need to change this to eitherkCLAuthorizzationStatusAuthorizedWhenInUse
orkCLAuthorizationStatusAuthorizedAlways
. Note thatkCLAuthorizationStatusAuthorized
is equal tokCLAuthorizationStatusAuthorizedAlways
.
More details can be found on this very good blog post:
http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/