Skip to content

Commit f52b2cf

Browse files
committed
fix: use instance property for CLLocationManager authorizationStatus
The class method +[CLLocationManager authorizationStatus] was deprecated in macOS 11.0. Switch to the instance property instead. Also fix the default case to return 'not determined' instead of 'denied' for kCLAuthorizationStatusNotDetermined.
1 parent 7e9618c commit f52b2cf

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

permissions.mm

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,15 +371,16 @@ bool HasOpenSystemPreferencesDialog() {
371371
// Returns a status indicating whether the user has authorized location
372372
// access.
373373
std::string LocationAuthStatus() {
374-
switch ([CLLocationManager authorizationStatus]) {
374+
CLLocationManager *manager = [[CLLocationManager alloc] init];
375+
switch (manager.authorizationStatus) {
375376
case kCLAuthorizationStatusAuthorized:
376377
return kAuthorized;
377378
case kCLAuthorizationStatusDenied:
378379
return kDenied;
379380
case kCLAuthorizationStatusRestricted:
380381
return kRestricted;
381382
default:
382-
return kDenied;
383+
return kNotDetermined;
383384
}
384385
}
385386

0 commit comments

Comments
 (0)