Skip to content

Commit

Permalink
Ensures [CLLocationManager locationServicesEnabled] is called on back…
Browse files Browse the repository at this point in the history
…ground thread (#1399)

* Call locationServiceEnabled on separate thread

* Update version number

* Remove redundant empty lines
  • Loading branch information
mvanbeusekom authored Dec 27, 2023
1 parent b311084 commit 6fb962c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions geolocator_apple/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.3.3

* Ensures the `[CLLocationManager locationServicesEnabled]` message is called
on a background thread when listening for service updates.

## 2.3.2

* Fixes build error and warnings regarding unused variables and unavailable APIs on macOS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,16 @@ - (FlutterError * _Nullable)onListenWithArguments:(id _Nullable)arguments eventS
}

- (void)locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status{
if ([CLLocationManager locationServicesEnabled]) {
_eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]);
} else {
_eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]);
}
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
BOOL isEnabled = [CLLocationManager locationServicesEnabled];
dispatch_async(dispatch_get_main_queue(), ^(void) {
if (isEnabled) {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)enabled]);
} else {
self->_eventSink([NSNumber numberWithInt:(ServiceStatus)disabled]);
}
});
});
}

@end
2 changes: 1 addition & 1 deletion geolocator_apple/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: geolocator_apple
description: Geolocation Apple plugin for Flutter. This plugin provides the Apple implementation for the geolocator.
repository: https://github.com/baseflow/flutter-geolocator/tree/main/geolocator_apple
issue_tracker: https://github.com/baseflow/flutter-geolocator/issues?q=is%3Aissue+is%3Aopen
version: 2.3.2
version: 2.3.3

environment:
sdk: ">=2.15.0 <4.0.0"
Expand Down

0 comments on commit 6fb962c

Please sign in to comment.