LocationManager

open class LocationManager : NSObject
extension LocationManager: CLLocationManagerDelegate

A singleton object that is responsible for handling location related data and events

  • The expected key of the Notification‘s userInfo that contains the Event object

    Declaration

    Swift

    public static let eventKey: String
  • Different events that the LocationManager can broadcast to its listeners

    See more

    Declaration

    Swift

    public enum Event
  • The native CLLocationManager

    Declaration

    Swift

    public private(set) var manager: CLLocationManager!

Location

  • The latest location depending on its validity

    Declaration

    Swift

    open var lastKnownLocation: CLLocation? { get }

Flags

  • Boolean value indicating wether the application is authorized to use the location services

    Declaration

    Swift

    open var isAuthorized: Bool { get }
  • Checks the validity of the given location based on the timestamp and horizontal accuracy. Basically, it’s just a sanity check to make sure that the location really changed.

    Declaration

    Swift

    open func isLocationValid(_ location: CLLocation) -> Bool
  • Checks if the device’s GPS is enabled

    Declaration

    Swift

    open var isLocationServicesEnabled: Bool { get }

Init

  • Singleton property

    Declaration

    Swift

    public static let shared: LocationManager

Location Updates

Authorization

  • Checks the location service’s authorization status and passes it to handleAuthorizationStatus handler

    Declaration

    Swift

    open func checkAndRequestAuthorizationIfNeeded()
  • Checks the location service’s authorization status and emits a specific event to the listeners depending on the status.

    Declaration

    Swift

    open func handleAuthorizationStatus(_ status: CLAuthorizationStatus)
  • Checks if the given CLAuthorizationStatus is either authorizedWhenInUse or authorizedAlways

    Declaration

    Swift

    open func isStatusAllowed(_ status: CLAuthorizationStatus) -> Bool

Events

  • Posts a Notification containing the LocationManager.Event inside the userInfo‘s “event” key to notify the observers that the said did occur

    Declaration

    Swift

    open func broadcastEvent(_ event: LocationManager.Event)

CLLocationManagerDelegate