Location Services not working in iOS 8

前端 未结 26 1976
滥情空心
滥情空心 2020-11-21 10:23

My app that worked fine on iOS 7 doesn\'t work with the iOS 8 SDK.

CLLocationManager doesn\'t return a location, and I don\'t see my app under

26条回答
  •  旧巷少年郎
    2020-11-21 10:26

    Solution with backward compatibility which doesn't produce Xcode warnings:

    SEL requestSelector = NSSelectorFromString(@"requestWhenInUseAuthorization");
    if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusNotDetermined &&
      [self.locationManager respondsToSelector:requestSelector]) {
    ((void (*)(id, SEL))[self.locationManager methodForSelector:requestSelector])(self.locationManager, requestSelector);
      [self.locationManager startUpdatingLocation];
    } else {
      [self.locationManager startUpdatingLocation];
    }
    

    Setup NSLocationWhenInUseUsageDescription key in your Info.plist.

    For iOS version 11.0+ : Setup NSLocationAlwaysAndWhenInUseUsageDescription key in your Info.plist. along with other 2 keys.

提交回复
热议问题