【发布时间】:2015-12-07 08:53:54
【问题描述】:
在设置应用 > 隐私 > 定位服务 > 我的应用 > 从不处于后台模式时,didChangeAuthorizationStatus 被称为 kCLAuthorizationStatusDenied 状态。 但是在更改“始终”之后,不会调用 didChangeAuthorizationStatus。 关闭“定位服务”时也不会调用。
我在 Info.plist 中插入了 NSLocationAlwaysUsageDescription 并设置了位置更新后台模式。
我的代码,
- (id)init {
self = [super init];
if (self) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.pausesLocationUpdatesAutomatically = NO;
if ([_locationManager respondsToSelector:@selector(setAllowsBackgroundLocationUpdates:)]) {
NSLog(@"setAllowsBackgroundLocationUpdates");
_locationManager.allowsBackgroundLocationUpdates = YES;
}
[self requestAuthorization];
}
return self;
}
- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status {
NSLog(@"CLAuthorizationStatus: %d", status);
}
对不起我的英语。
【问题讨论】:
标签: ios core-location cllocationmanager