File tree Expand file tree Collapse file tree 4 files changed +24
-4
lines changed
Sources/d3-async-location Expand file tree Collapse file tree 4 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 66- [x] Customizable in terms of CLLocationManager properties
77- [x] Streaming current locations asynchronously
88- [x] Support for iOS and watchOS
9- - [x] Errors handling
9+ - [x] Errors handling (as custom so CoreLocation errors)
1010
1111## How to use
1212
@@ -52,6 +52,9 @@ If task will be canceled the streaming stops automatically. I would recomend to
5252
5353 /// Stream was cancelled or terminated
5454 case streamTerminated
55+
56+ /// A Core Location error
57+ case coreLocationManagerError(CLError)
5558```
5659
5760### LMViewModel API
@@ -85,6 +88,7 @@ public protocol ILocationManagerViewModel: ObservableObject{
85883 . Option tab
86894 . Already checked Core Location > select your location
87905 . Press OK
91+
8892 ![ Default location] ( https://github.com/The-Igor/d3-async-location/blob/main/img/image6.png )
8993
9094## SwiftUI example of using package
Original file line number Diff line number Diff line change @@ -40,8 +40,21 @@ extension LocationManagerAsync{
4040 NotificationCenter . default. post ( name: Permission . authorizationStatus, object: manager. authorizationStatus)
4141 }
4242
43+
44+ /// Tells the delegate that the location manager was unable to retrieve a location value
45+ /// - Parameters:
46+ /// - manager: The location manager object that was unable to retrieve the location
47+ /// - error: The error object containing the reason the location or heading could not be retrieved
4348 func locationManager( _ manager: CLLocationManager , didFailWithError error: Error ) {
44- print ( error)
49+ guard let e = error as? CLError else { return }
50+
51+ if e. code == CLError . locationUnknown{
52+ return /// glitch throwing this error on some devices and simulator while changing locations time by time
53+ }
54+
55+ let type = AsyncLocationErrors . self
56+ stream? . finish ( throwing: type. coreLocationManagerError ( e) )
57+
4558 }
4659
4760 // MARK: - Private
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ final class LocationManagerAsync: ILocationManagerAsync{
1616 /// Location manager
1717 private let manager = CLLocationManager ( )
1818
19- /// Delegate adapter
19+ /// Delegate
2020 private let delegate = Delegate ( )
2121
2222 // Streaming locations
Original file line number Diff line number Diff line change 55// Created by Igor on 03.02.2023.
66//
77
8- import Foundation
8+ import CoreLocation
99
1010/// Async locations manager errors
1111@available ( iOS 15 . 0 , watchOS 7 . 0 , * )
@@ -21,4 +21,7 @@ public enum AsyncLocationErrors: Error{
2121 /// Stream was cancelled or terminated
2222 case streamTerminated
2323
24+ /// A Core Location error
25+ case coreLocationManagerError( CLError )
26+
2427}
You can’t perform that action at this time.
0 commit comments