Skip to content

hardeep-singh/AsyncLocationManager

Repository files navigation

AsyncLocationManager

Swift Package Manager Swift Platforms

A wrapper for the Apple CoreLocation framework with the new Concurrency Model

Install


pod 'AsyncLocationManager'

Add the following line to your Package.swift file in the dependencies section:

.package(url: "https://github.com/hardeep-singh/AsyncLocationManager.git)

How to Use LocationManager


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
    }
}

License


AsyncLocationManager is released under the MIT license. See LICENSE for details.