Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ios): change native location accuracy values #2420

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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