https://github.com/koombea/location-manager-ios
https://github.com/koombea/location-manager-ios
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/koombea/location-manager-ios
- Owner: koombea
- Created: 2021-11-09T19:58:02.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-11T21:30:48.000Z (about 2 years ago)
- Last Synced: 2024-04-12T00:19:35.414Z (about 2 years ago)
- Language: Swift
- Size: 20.5 KB
- Stars: 0
- Watchers: 19
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Location Manager for iOS
[](https://opensource.org/licenses/Apache-2.0)
[](https://swift.org/package-manager/)
**Location Manager** is a library written in Swift that makes it easy for you to use Apple CoreLocation services.
## Requirements
- iOS 13.0+
## Installation
### Swift Package Manager
The Swift Package Manager is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
The Package Manager is included in Swift 3.0 and above.
```swift
.package(url: "https://github.com/koombea/location-manager-ios", from: "1.0.0")
```
## The Basics
### Location Authorization
```swift
let status = await LocationManager.requestAuthorization(for: .whenInUse)
```
### Background Location Authorization
It must be used after request `whenInUse` [Read more from Apple Docs](https://developer.apple.com/documentation/corelocation/cllocationmanager/1620551-requestalwaysauthorization)
```swift
let status = await LocationManager.requestAuthorization(for: .always)
```
### Notifications Observers
```swift
NotificationCenter.default.addObserver(self, selector: #selector(yourSelector),
name: LocationManager.authorizationStatusChanged, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(yourSelector),
name: LocationManager.locationManagerDidFail, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(yourSelector),
name: LocationManager.locationUpdated, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(yourSelector),
name: LocationManager.authorizedBackgroundLocation, object: nil)
```