gpt4 book ai didi

iOS locationmanager didChangeAuthorizationStatus 未从 kCLAuthorizationStatusDenied 调用到 kCLAuthorizationStatusAuthorized 状态

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:13:21 24 4
gpt4 key购买 nike

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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com