- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
didChangeAuthorizationStatus 在设置 app > Privacy > Location Services > My app > Never in background mode 中被称为 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);
}
对不起我的英语。
最佳答案
我遇到了这个确切的问题,结果我正在创建我的 CLLocationManager
并调用
-requestWhenInUseAuthorization
在后台线程上。我在 主线程 上调用了这些方法并获得了预期的结果(-locationManager:didChangedAithorizationStatus:
在我点击“不允许”或“允许”后被调用)
关于iOS locationmanager didChangeAuthorizationStatus 未从 kCLAuthorizationStatusDenied 调用到 kCLAuthorizationStatusAuthorized 状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34129647/
当应用程序处于后台时,我似乎没有收到 delegate 方法的通知。一旦应用程序进入前台,我就会收到 didChangeAuthorizationStatus。有没有其他人在后台成功获取 author
我有一个 View Controller ,它实现了 CLLocationManagerDelegate。我创建了一个 CLLocationManager 变量: let locationManage
我想在方法 didChangeAuthorizationStatus 中调用 startMonitoringForRegion 并且一切正常,主要是因为代码是从 Estimote 示例中复制的。此代码
didChangeAuthorizationStatus 在设置 app > Privacy > Location Services > My app > Never in background mo
我是一名优秀的程序员,十分优秀!