A wrapper for the Apple CoreLocation framework with the new Concurrency Model
pod 'AsyncLocationManager'
Add the following line to your Package.swift file in the dependencies section:
.package(url: "https://github.com/hardeep-singh/AsyncLocationManager.git)
Create instance of the LocationManager
let locationManager = LocationManager()Request Location Authorization permissions
let authorizationStatus = try await locationManager.requestAuthorizationPermission(.always)Request a single location
let location = try await locationManager.requestLocation()Start monitoring and updating location
for await location in await locationManager.startUpdatingLocation() {
switch location {
case .didFailWithError(let error):
print("Location:- \(error)")
case .didPaused:
print("Location Did Paused")
break
case .didResume:
print("Location Did Resume")
break
case .didUpdateLocations(let locations):
print("Location Did Update:- \(locations)")
break
}
}AsyncLocationManager is released under the MIT license. See LICENSE for details.