Skip to content

Commit

Permalink
feat(ios): change native location accuracy values (#2420)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcesarmobile authored Feb 7, 2020
1 parent a1b6403 commit 16c3ea1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions ios/Capacitor/Capacitor/Plugins/Geolocation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
}
Expand Down

0 comments on commit 16c3ea1

Please sign in to comment.