gpt4 book ai didi

macos - 为什么 CoreLocation (Mac OS X) 不记得我允许其使用的选择?

转载 作者:行者123 更新时间:2023-12-03 16:40:47 24 4
gpt4 key购买 nike

我可能很愚蠢,但我无法弄清楚为什么会发生以下情况:

我在 Mac OS X 上有一个使用 CoreLocation 的应用程序。下面是相关代码:

它每次启动时都会请求使用我的位置的权限,并且永远不会记得我已经授予使用位置数据的权限。

该应用程序永远不会出现在“隐私”首选项 Pane 中。

我错过了什么吗?

谢谢。

#pragma mark - General Instance Methods

- (void)determineLocation
{
if (self.locationManager)
{
DDLogWarn(@"determinLocation called, but we already have a locationManager instance variable...");
DDLogWarn(@"This is a bug.");
}

self.currentlocationName = @"Location unknown";
if (![CLLocationManager locationServicesEnabled])
{
DDLogWarn(@"Location Services not enabled.");
[self fallBackToHardcodedLocation];
return;
}

// Location services are available.
self.locationManager = [[CLLocationManager alloc] init];
self.locationManager.delegate = self;


// Coarse-grained location accuracy required.
self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
self.locationManager.distanceFilter = 1000; // meters - 1km
[self.locationManager startUpdatingLocation];
}



#pragma mark - Location Manager Delegate Methods


- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
{
DDLogVerbose(@"Our authorisation to use the location manager has changed.");
switch (status) {
case kCLAuthorizationStatusNotDetermined:
DDLogError(@"LocationManager Authorisation status not determined. (User hasn't chosen yet)");
break;

case kCLAuthorizationStatusAuthorized:
DDLogVerbose(@"We are now authorised for locationServices.");
[self.locationManager startUpdatingLocation];
break;

case kCLAuthorizationStatusDenied:
DDLogWarn(@"LocationManager: We are now explicitly denied!");
[self.locationManager stopUpdatingLocation];
break;

case kCLAuthorizationStatusRestricted:
DDLogWarn(@"LocationManager We are now restricted! (not authorised - perhaps due to parental controls...)");
[self.locationManager stopUpdatingLocation];
break;

default:
break;
}
}

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
// Main callback for location discovery..§

CLLocation* location = [locations lastObject];
NSDate* eventDate = location.timestamp;
NSTimeInterval howRecent = [eventDate timeIntervalSinceNow];
if (abs(howRecent) < 15.0)
{
// Event is recent. Do something with it.
if (location.horizontalAccuracy > 1000)
{
DDLogWarn(@"Location Accuracy is worse than 1km, discarding...");
} else {
[self updateLocation:location];
}
return;
}

DDLogWarn(@"Stale location data...");
[self updateLocation:location];
}

它总是请求许可:(kCLAuthorizationStatusNotDetermined 似乎总是如此。)

 2015-02-07 01:03:36:127 Central Heating[2260:30b] LocationManager Authorisation status not determined. (User hasn't chosen yet)

CoreLocation permission always asked(对话框文本:“中央供暖”想要使用您当前的位置。天气预报需要您的位置。[不允许][确定])

最佳答案

正如戈登提到的,这个问题可以通过签署应用程序来解决。

关于macos - 为什么 CoreLocation (Mac OS X) 不记得我允许其使用的选择?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28377503/

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