pod 'AsyncLocationKit', :git => 'https://github.com/AsyncSwift/AsyncLocationKit.git', :tag => '1.6.2'
Initialize AsyncLocationManager only synchronously on MainThread
import AsyncLocationKit
let asyncLocationManager = AsyncLocationManager(desiredAccuracy: .bestAccuracy)
Task {
let permission = await self.asyncLocationManager.requestAuthorizationWhenInUse() //returns CLAuthorizationStatus
}
You can use all methods from Apple CLLocationManager.
Task {
let coordinate = try await asyncLocationManager.requestLocation() //Request user location once
}
Start monitoring update of user location with AsyncStream.
Task {
for await locationUpdateEvent in await asyncLocationManager.startUpdatingLocation() {
switch locationUpdateEvent {
case .didUpdateLocations(let locations):
// do something
case .didFailWith(let error):
// do something
case .didPaused, .didResume:
break
}
}
}
If Task was canceled, Stream finished automaticaly.
AsyncLocationKit
Wrapper for Apple
CoreLocation
framework with new Concurency Model. No moredelegate
pattern orcompletion blocks
.Install
SPM
Cocoapods
You can use all methods from Apple
CLLocationManager
.Start monitoring update of user location with
AsyncStream
.If
Task
was canceled, Stream finished automaticaly.