标签:
@property(assign,nonatomic) BOOL allowsBackgroundLocationUpdates注意:iOS9.0 可以单次请求用户位置
- (void)requestLocation  
// 成功调用,locations位置数组,元素按照时间排序
-(void)locationManager:(nonnull CLLocationManager *)manager didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations 
// 失败调用
-(void)locationManager:(nonnull CLLocationManager *)manager didFailWithError:(nonnull NSError *)error不能与startUpdatingLocation方法同时使用 #import <CoreLocation/CoreLocation.h>
_locationM = [[CLLocationManager alloc] init];
  _locationM.delegate = self;
  if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) 
      {
          [_locationM requestWhenInUseAuthorization];
      }[_locationM startUpdatingLocation];-(void)locationManager:(nonnull CLLocationManager *)manager didUpdateLocations:(nonnull NSArray<CLLocation *> *)locations方案一:在APP处于前台定位授权场景下,勾选后台运行模式update locations (如下图) 并且,调用以下方法,设置允许后台定位

if ([[UIDevice currentDevice].systemVersion floatValue] >= 9.0) {
   _locationM.allowsBackgroundLocationUpdates = YES;
}注意:如果APP处于后台,则会出现蓝条方案二:请求前后台定位授权,并配置KEY
[_locationM requestAlwaysAuthorization];标签:
原文地址:http://www.cnblogs.com/bolin-123/p/5343156.html