diff --git a/geolocation/ios/Sources/GeolocationPlugin/GeolocationPlugin.swift b/geolocation/ios/Sources/GeolocationPlugin/GeolocationPlugin.swift index e25afa011..d43d7add1 100644 --- a/geolocation/ios/Sources/GeolocationPlugin/GeolocationPlugin.swift +++ b/geolocation/ios/Sources/GeolocationPlugin/GeolocationPlugin.swift @@ -38,7 +38,7 @@ public class GeolocationPlugin: CAPPlugin, CLLocationManagerDelegate, CAPBridged self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers } - if CLLocationManager.authorizationStatus() == .notDetermined { + if self.locationManager.authorizationStatus == .notDetermined { self.locationManager.requestWhenInUseAuthorization() } else { self.locationManager.requestLocation() @@ -59,7 +59,7 @@ public class GeolocationPlugin: CAPPlugin, CLLocationManagerDelegate, CAPBridged self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers } - if CLLocationManager.authorizationStatus() == .notDetermined { + if self.locationManager.authorizationStatus == .notDetermined { self.locationManager.requestWhenInUseAuthorization() } else { self.locationManager.startUpdatingLocation() @@ -121,13 +121,15 @@ public class GeolocationPlugin: CAPPlugin, CLLocationManagerDelegate, CAPBridged } } - public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { + public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { let removalQueue = callQueue.filter { $0.value == .permissions } callQueue = callQueue.filter { $0.value != .permissions } for (id, _) in removalQueue { if let call = bridge?.savedCall(withID: id) { - checkPermissions(call) + DispatchQueue(label: "permissionsQueue").async { + self.checkPermissions(call) + } bridge?.releaseCall(call) } } @@ -161,7 +163,7 @@ public class GeolocationPlugin: CAPPlugin, CLLocationManagerDelegate, CAPBridged var status: String = "" if CLLocationManager.locationServicesEnabled() { - switch CLLocationManager.authorizationStatus() { + switch self.locationManager.authorizationStatus { case .notDetermined: status = "prompt" case .restricted, .denied: @@ -188,7 +190,7 @@ public class GeolocationPlugin: CAPPlugin, CLLocationManagerDelegate, CAPBridged if CLLocationManager.locationServicesEnabled() { // If state is not yet determined, request perms. // Otherwise, report back the state right away - if CLLocationManager.authorizationStatus() == .notDetermined { + if self.locationManager.authorizationStatus == .notDetermined { bridge?.saveCall(call) callQueue[call.callbackId] = .permissions