Location services error after updating to iOS8

I am trying to support iOS7 and 8 search services. When I start my iOS8 device, I get this error:

"MyApp depending on legacy on-demand authorization, which is not supported for new apps"

      

I have a when used entry in my plist. Here's my code:

    if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) {
        [_locationManager requestWhenInUseAuthorization];
    } else {
        [_locationManager startUpdatingLocation];
    }


- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
  if (status == kCLAuthorizationStatusAuthorizedWhenInUse) {
    [_locationManager startUpdatingLocation];
  }
}

      

Why does this error appear?

+3


source to share


3 answers


I used a legacy callback from location services and didn't implement a new one. There was no compiler warning, but developers reading this should check the documentation for location services delegates in their code.

DELETE is the first method in the delegate documentation. This whole question was an RTFM case.



  • (void) locationManager: (CLLocationManager *) didUpdateToLocation manager: (CLLocation *) newLocation fromLocation: (CLLocation *) oldLocation __OSX_AVAILABLE_BUT_DEPRECATED (__ MAC_10_6, __MAC_NAIP2); __
+3


source


The reason you are getting this error in swift is because you did not ask the user for explicit permission to use location services, which would be fine before iOS 8. Starting with iOS 8, you must explicitly ask for permission to use the services determining the location.

IOS version> = 8

self.locationManager.requestAlwaysAuthorization()
self.locationManager.startMonitoringSignificantLocationChanges()

      



IOS version <8

self.locationManager.startMonitoringSignificantLocationChanges()

      

+1


source


Add these two keys to info.plist with the "Location required to know where you are" value string.

NSLocationWhenInUseUsageDescription NSLocationAlwaysUsageDescription

0


source







All Articles