Skip to content

Commit bb9ba6a

Browse files
committed
Add Accuracy setting
1 parent 2938ddb commit bb9ba6a

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
import Foundation
12

3+
public let version: String = "1.0.0"

Sources/AsyncLocationKit/AsyncLocationManager.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ public final class AsyncLocationManager {
1414
public private(set) var locationManager: CLLocationManager
1515
private var proxyDelegate: AsyncDelegateProxyInterface
1616
private var locationDelegate: CLLocationManagerDelegate
17+
private var desiredAccuracy: LocationAccuracy = .bestAccuracy
1718

1819
public init() {
1920
locationManager = CLLocationManager()
2021
proxyDelegate = AsyncDelegateProxy()
2122
locationDelegate = LocationDelegate(delegateProxy: proxyDelegate)
2223
locationManager.delegate = locationDelegate
24+
locationManager.desiredAccuracy = desiredAccuracy.convertingAccuracy
25+
}
26+
27+
public convenience init(desiredAccuracy: LocationAccuracy) {
28+
self.init()
29+
self.desiredAccuracy = desiredAccuracy
2330
}
2431

2532
public func requestAuthorizationWhenInUse() async -> CLAuthorizationStatus {
File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
import CoreLocation
3+
4+
/// Wrapper for CLLocationAccuracy
5+
public enum LocationAccuracy {
6+
case bestAccuracy
7+
case nearestTenMetersAccuracy
8+
case hundredMetersAccuracy
9+
case kilometerAccuracy
10+
case threeKilometersAccuracy
11+
case bestForNavigationAccuracy
12+
13+
internal var convertingAccuracy: CLLocationAccuracy {
14+
switch self {
15+
case .bestAccuracy:
16+
return kCLLocationAccuracyBest
17+
case .nearestTenMetersAccuracy:
18+
return kCLLocationAccuracyNearestTenMeters
19+
case .hundredMetersAccuracy:
20+
return kCLLocationAccuracyHundredMeters
21+
case .kilometerAccuracy:
22+
return kCLLocationAccuracyKilometer
23+
case .threeKilometersAccuracy:
24+
return kCLLocationAccuracyThreeKilometers
25+
case .bestForNavigationAccuracy:
26+
return kCLLocationAccuracyBestForNavigation
27+
}
28+
}
29+
30+
}

0 commit comments

Comments
 (0)