@@ -12,7 +12,7 @@ import CoreLocation
1212final class LocationManagerAsync : ILocationManagerAsync {
1313
1414 // MARK: - Private properties
15-
15+
1616 /// Location manager
1717 private let manager = CLLocationManager ( )
1818
@@ -24,8 +24,8 @@ final class LocationManagerAsync: ILocationManagerAsync{
2424 /// Async stream of ``CLLocation``
2525 private var locations : AsyncThrowingStream < CLLocation , Error > {
2626 . init( CLLocation . self) { continuation in
27- streaming ( with: continuation)
28- }
27+ streaming ( with: continuation)
28+ }
2929 }
3030
3131 // MARK: - Life circle
@@ -42,22 +42,23 @@ final class LocationManagerAsync: ILocationManagerAsync{
4242
4343 updateSettings ( accuracy, activityType, distanceFilter, backgroundUpdates)
4444 }
45-
46-
45+
46+
4747 // MARK: - API
4848
4949 /// Check status and get stream of async data Throw an error ``AsyncLocationErrors`` if permission is not granted
5050 public var start : AsyncThrowingStream < CLLocation , Error > {
5151 get async throws {
5252 let permission = Permission ( with: manager. authorizationStatus)
5353
54- if await permission. isGranted ( for: manager) {
55- #if DEBUG
56- print ( " start " )
57- #endif
58- return locations
59- }
60- throw AsyncLocationErrors . accessIsNotAuthorized
54+ try await permission. grant ( for: manager)
55+
56+ #if DEBUG
57+ print ( " start " )
58+ #endif
59+
60+ return locations
61+
6162 }
6263 }
6364
@@ -72,7 +73,7 @@ final class LocationManagerAsync: ILocationManagerAsync{
7273 }
7374
7475 // MARK: - Private
75-
76+
7677 // Streaming locations
7778
7879 /// Start updating
@@ -101,5 +102,3 @@ final class LocationManagerAsync: ILocationManagerAsync{
101102 manager. allowsBackgroundLocationUpdates = backgroundUpdates
102103 }
103104}
104-
105-
0 commit comments