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 theEvent
objectDeclaration
Swift
public static let eventKey: String
-
Different events that the
See moreLocationManager
can broadcast to its listenersDeclaration
Swift
public enum Event
-
The native
CLLocationManager
Declaration
Swift
public private(set) var manager: CLLocationManager!
-
The latest location depending on its validity
Declaration
Swift
open var lastKnownLocation: CLLocation? { get }
-
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 }
-
Singleton property
Declaration
Swift
public static let shared: LocationManager
-
Starts the receiving of location updates
Declaration
Swift
open func startReceivingLocationUpdates()
-
Stops the receiving of location updates
Declaration
Swift
open func stopReceivingLocationUpdates()
-
Checks the location service’s authorization status and passes it to
handleAuthorizationStatus
handlerDeclaration
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 eitherauthorizedWhenInUse
orauthorizedAlways
Declaration
Swift
open func isStatusAllowed(_ status: CLAuthorizationStatus) -> Bool
-
Posts a
Notification
containing theLocationManager.Event
inside theuserInfo
‘s “event
” key to notify the observers that the said did occurDeclaration
Swift
open func broadcastEvent(_ event: LocationManager.Event)
-
Undocumented
Declaration
Swift
public func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus)
-
Undocumented
Declaration
Swift
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
-
Undocumented
Declaration
Swift
public func locationManager(_ manager: CLLocationManager, didFailWithError error: Error)