AsyncLocationKit Save

đź“Ťasync/await CoreLocation

Project README

AsyncLocationKit

Swift Package Manager Swift Platforms

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

Install


SPM
dependencies: [
    .package(url: "https://github.com/AsyncSwift/AsyncLocationKit.git", .upToNextMinor(from: "1.6.4"))
]

Cocoapods

pod 'AsyncLocationKit', :git => 'https://github.com/AsyncSwift/AsyncLocationKit.git', :tag => '1.6.4'

:warning: Initialize AsyncLocationManager only synchronously on MainThread

import AsyncLocationKit

let asyncLocationManager = AsyncLocationManager(desiredAccuracy: .bestAccuracy)

let permission = await self.asyncLocationManager.requestAuthorizationWhenInUse() //returns CLAuthorizationStatus

You can use all methods from Apple CLLocationManager.

let coordinate = try await asyncLocationManager.requestLocation() //Request user location once

Start monitoring update of user location with AsyncStream.

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 cancelled, Stream finished automaticaly.

Open Source Agenda is not affiliated with "AsyncLocationKit" Project. README Source: AsyncSwift/AsyncLocationKit
Stars
172
Open Issues
1
Last Commit
6 months ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating