From daf38b137bc9c287ddc5c6c44e4d5a34dab3ede8 Mon Sep 17 00:00:00 2001 From: honghai2196 <24835894+honghai2196@users.noreply.github.com> Date: Tue, 4 Jun 2024 15:59:18 +0700 Subject: [PATCH] =?UTF-8?q?[LocationPermission]=20Fix=20warning=20UI=20unr?= =?UTF-8?q?esponsive=20in=20mainthread=20when=20c=E2=80=A6=20(#1329)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [LocationPermission] Fix warning UI unresponsive in mainthread when calling locationServicesEnabled * fix issue #1002: bump version, fix Xcode location check warning * fix issue #1002: Xcode warning of the unresponsive of main thread when checking location state * bump version to 11.3.2 * bump version to 11.3.2: update changelog and fix #1002 * update permission_handler_apple dependency to minimum 9.4.5 * revert permission_handler_apple dependency * revert CHANGELOG.md * revert pubspec.yaml --- permission_handler_apple/CHANGELOG.md | 4 ++++ .../ios/Classes/strategies/LocationPermissionStrategy.m | 8 +++++++- permission_handler_apple/pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/permission_handler_apple/CHANGELOG.md b/permission_handler_apple/CHANGELOG.md index 495783a7e..05dd219d7 100644 --- a/permission_handler_apple/CHANGELOG.md +++ b/permission_handler_apple/CHANGELOG.md @@ -1,3 +1,7 @@ +## 9.4.5 + +* Fixes issue #1002, Xcode warning of the unresponsive of main thread when checking isLocationEnabled. + ## 9.4.4 * Fixes potentially-nil return type of EventPermissionStrategy#getEntityType. diff --git a/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m b/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m index 7e5b0b689..a4f6b21f4 100644 --- a/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m +++ b/permission_handler_apple/ios/Classes/strategies/LocationPermissionStrategy.m @@ -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 { diff --git a/permission_handler_apple/pubspec.yaml b/permission_handler_apple/pubspec.yaml index ae32542a0..ef6679c56 100644 --- a/permission_handler_apple/pubspec.yaml +++ b/permission_handler_apple/pubspec.yaml @@ -2,7 +2,7 @@ name: permission_handler_apple description: Permission plugin for Flutter. This plugin provides the iOS API to request and check permissions. repository: https://github.com/baseflow/flutter-permission-handler issue_tracker: https://github.com/Baseflow/flutter-permission-handler/issues -version: 9.4.4 +version: 9.4.5 environment: sdk: ">=2.15.0 <4.0.0"