What's New

1.5.0

2022-06-12T20:38:34Z

What's Changed

Full Changelog: 1.0.4...1.0.5

AsyncLocationKit

Swift Package Manager Swift Platforms

Wrapper for Apple CoreLocation framework with new Concurency Model. No more delegate pattern or completion blocks.

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.

Description

  • Swift Tools 5.5.0
View More Packages from this Author

Dependencies

  • None
Last updated: Wed Jun 29 2022 01:06:25 GMT-0500 (GMT-05:00)