Skip to content

Commit

Permalink
RMET-3808 ::: Geolocation ::: iOS ::: Remove iOS 14 Deprecated Code (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
OS-ricardomoreirasilva authored Oct 28, 2024
1 parent 780a71f commit d73d33b
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down

0 comments on commit d73d33b

Please sign in to comment.