Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AsyncSwift/AsyncLocationKit
đź“Ťasync/await CoreLocation
https://github.com/AsyncSwift/AsyncLocationKit
async-await concurency framework location location-service swift swiftpackage swiftpackagemanager
Last synced: 3 days ago
JSON representation
đź“Ťasync/await CoreLocation
- Host: GitHub
- URL: https://github.com/AsyncSwift/AsyncLocationKit
- Owner: AsyncSwift
- License: mit
- Created: 2022-01-02T13:04:53.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-10-06T19:42:49.000Z (about 1 year ago)
- Last Synced: 2024-04-28T20:39:12.536Z (8 months ago)
- Topics: async-await, concurency, framework, location, location-service, swift, swiftpackage, swiftpackagemanager
- Language: Swift
- Homepage:
- Size: 126 KB
- Stars: 172
- Watchers: 4
- Forks: 25
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios - AsyncLocationKit - Wrapper for Apple CoreLocation framework with Modern Concurrency Swift (async/await). (Hardware / Location)
- awesome-swift - AsyncLocationKit - Wrapper for Apple CoreLocation framework with Modern Concurrency Swift (async/await). (Libs / Location)
- awesome-ios-star - AsyncLocationKit - Wrapper for Apple CoreLocation framework with Modern Concurrency Swift (async/await). (Hardware / Location)
- fucking-awesome-swift - AsyncLocationKit - Wrapper for Apple CoreLocation framework with Modern Concurrency Swift (async/await). (Libs / Location)
README
# AsyncLocationKit
[![Swift Package Manager](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat)](https://img.shields.io/badge/Swift_Package_Manager-compatible-orange?style=flat)
[![Swift](https://img.shields.io/badge/Swift-5.5-orange?style=flat)](https://img.shields.io/badge/Swift-5.5-Orange?style=flat)
[![Platforms](https://img.shields.io/badge/platforms-iOS--13%20|%20macOS(beta)%20|%20watchOS--6(beta)%20|%20tvOS(beta)-orange?style=flat)](https://img.shields.io/badge/platforms-iOS--13%20|%20macOS(beta)%20|%20watchOS--6(beta)%20|%20tvOS(beta)-orange?style=flat)Wrapper for Apple `CoreLocation` framework with new Concurrency Model. No more `delegate` pattern or `completion blocks`.
### Install
---
##### SPM
```swift
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**
```swift
import AsyncLocationKitlet asyncLocationManager = AsyncLocationManager(desiredAccuracy: .bestAccuracy)
let permission = await self.asyncLocationManager.requestAuthorizationWhenInUse() //returns CLAuthorizationStatus
```You can use all methods from Apple `CLLocationManager`.
```swift
let coordinate = try await asyncLocationManager.requestLocation() //Request user location once
```Start monitoring update of user location with `AsyncStream`.
```swift
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.