From d73d33b36677cfdcebec346e40aa53366d8b5481 Mon Sep 17 00:00:00 2001 From: Ricardo Silva <97543217+OS-ricardomoreirasilva@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:16:20 +0000 Subject: [PATCH] RMET-3808 ::: Geolocation ::: iOS ::: Remove iOS 14 Deprecated Code (#2225) --- .../GeolocationPlugin/GeolocationPlugin.swift | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) 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