Skip to content

koombea/location-manager-ios

Repository files navigation

Location Manager for iOS

License Swift 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.

.package(url: "https://github.com/koombea/location-manager-ios", from: "1.0.0")

The Basics

Location Authorization

let status = await LocationManager.requestAuthorization(for: .whenInUse)

Background Location Authorization

It must be used after request whenInUse Read more from Apple Docs

let status = await LocationManager.requestAuthorization(for: .always)	

Notifications Observers

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)