From 489d0d3f855a82e2eff21c1e52c980ffa917f31a Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Fri, 7 Feb 2020 14:53:32 +0100 Subject: [PATCH] feat(ios): change native location accuracy values (#2420) --- ios/Capacitor/Capacitor/Plugins/Geolocation.swift | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ios/Capacitor/Capacitor/Plugins/Geolocation.swift b/ios/Capacitor/Capacitor/Plugins/Geolocation.swift index 6b16e339c0..8f384ad415 100644 --- a/ios/Capacitor/Capacitor/Plugins/Geolocation.swift +++ b/ios/Capacitor/Capacitor/Plugins/Geolocation.swift @@ -14,7 +14,7 @@ public struct GeolocationCoords { class GetLocationHandler: NSObject, CLLocationManagerDelegate { var locationManager = CLLocationManager() var call: CAPPluginCall - + init(call: CAPPluginCall, options: [String:Any]) { self.call = call @@ -23,19 +23,24 @@ class GetLocationHandler: NSObject, CLLocationManagerDelegate { // TODO: Allow user to configure accuracy, request/authorization mode self.locationManager.delegate = self self.locationManager.requestWhenInUseAuthorization() + let shouldWatch = options["watch"] as! Bool if call.getBool("enableHighAccuracy", false)! { + if shouldWatch { self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation - } else { + } else { self.locationManager.desiredAccuracy = kCLLocationAccuracyBest + } + } else { + self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers } - - if let shouldWatch = options["watch"], shouldWatch as? Bool == true { + + if shouldWatch { self.locationManager.startUpdatingLocation() } else { self.locationManager.requestLocation() } } - + public func stopUpdating() { self.locationManager.stopUpdatingLocation() }