Skip to content

Commit

Permalink
[LocationPermission] Fix warning UI unresponsive in mainthread when c…
Browse files Browse the repository at this point in the history
…alling locationServicesEnabled
  • Loading branch information
honghai2196 authored May 30, 2024
1 parent 724e327 commit 5e97c6e
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ - (PermissionStatus)checkPermissionStatus:(PermissionGroup)permission {
}

- (void)checkServiceStatus:(PermissionGroup)permission completionHandler:(ServiceStatusHandler)completionHandler {
completionHandler([CLLocationManager locationServicesEnabled] ? ServiceStatusEnabled : ServiceStatusDisabled);
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
BOOL isEnabled = [CLLocationManager locationServicesEnabled];

dispatch_async(dispatch_get_main_queue(), ^(void) {
completionHandler(isEnabled ? ServiceStatusEnabled : ServiceStatusDisabled);
});
});
}

- (void)requestPermission:(PermissionGroup)permission completionHandler:(PermissionStatusHandler)completionHandler errorHandler:(PermissionErrorHandler)errorHandler {
Expand Down

0 comments on commit 5e97c6e

Please sign in to comment.