LocationEngineBase
public protocol LocationEngineBase : AnyObject
Public protocol that describes the behaviour of LocationEngine.
Implementation is platform-specific.
-
The last known location obtained by the
LocationEngine. It is persisted throughout the app’s lifecycle.Declaration
Swift
var lastKnownLocation: Location? { get } -
Checks if the engine is in started state.
Declaration
Swift
var isStarted: Bool { get } -
Starts the location engine with desired
LocationAccuracy. ReturnsLocationEngineStatus.alreadyStarted, ifstart(LocationOptions)is called again withoutstop(...)in between.Declaration
Swift
func start(locationAccuracy: LocationAccuracy) -> LocationEngineStatusParameters
locationAccuracyDesired location accuracy. Requested accuracy is not guaranteed.
Return Value
Engine status. Valid values are defined in
LocationEngineStatus -
Reconfigures the location engine with desired
LocationAccuracy. This method is a faster way to change location accuracy for already started location engine, than callingstop(...)andstart(LocationOptions)in sequence. ReturnsLocationEngineStatus.notReady, if called for unstarted location engine.Declaration
Swift
func updateLocationAccuracy(locationAccuracy: LocationAccuracy) -> LocationEngineStatusParameters
locationAccuracyDesired location accuracy. Requested accuracy is not guaranteed.
Return Value
Engine status. Valid values are defined in
LocationEngineStatus -
Stops the location engine.
Declaration
Swift
func stop() -
Adds a
LocationDelegateto the engine to get notified when there is a new location update available. Supports more than one delegate, instance is added only once.Declaration
Swift
func addLocationDelegate(locationDelegate: LocationDelegate)Parameters
locationDelegateThe listener.
-
Removes a
LocationDelegatefrom the engine.Declaration
Swift
func removeLocationDelegate(locationDelegate: LocationDelegate)Parameters
locationDelegateThe listener.
-
Adds a
LocationStatusDelegateto the engine to get notified when there is an important status change. Supports more than one delegate, instance is added only once.Declaration
Swift
func addLocationStatusDelegate(locationStatusDelegate: LocationStatusDelegate)Parameters
locationStatusDelegateThe listener.
-
Removes a
LocationStatusDelegatefrom the engine.Declaration
Swift
func removeLocationStatusDelegate(locationStatusDelegate: LocationStatusDelegate)Parameters
locationStatusDelegateThe listener.
-
Enables or disables background location updates for an application. Defaults to
false.Declaration
Swift
func setBackgroundLocationAllowed(allowed: Bool) -> LocationEngineStatusParameters
allowedSet to
trueto allow background location updates, orfalseto disable them.Return Value
LocationEngineStatus.okif call succeeds.LocationEngineStatus.notAllowedif the application does not have background location capabilities enabled.LocationEngineStatus.notSupportedon platforms which do not support controlling of background location modes. -
Check if application’s background location updates are enabled. Returns
falseon platforms which do not support controlling of background location modes usingsetBackgroundLocationAllowed(...)method.Declaration
Swift
func getBackgroundLocationAllowed() -> BoolReturn Value
Trueif background location updates are allowed,falseotherwise. -
Controls visibility of application’s background location indicator. By default background location indicator is visible, if application has background location capabilities.
Declaration
Swift
func setBackgroundLocationIndicatorVisible(visible: Bool) -> LocationEngineStatusParameters
visibleSet to
trueto show background location indicator, orfalseto hide it.Return Value
LocationEngineStatus.okif call succeeds.LocationEngineStatus.notAllowedif the application does not have background location capabilities enabled.LocationEngineStatus.notSupportedon platforms which do not support controlling of background location indicator visibility. -
Check if application’s background location indicator is visible. Returns
falseon platforms which do not support controlling of background location indicator usingsetBackgroundLocationIndicatorVisible(...)method.Declaration
Swift
func getBackgroundLocationIndicatorVisible() -> BoolReturn Value
Trueif background location indicator is visible,falseotherwise. -
Controls automatic pausing of location updates e.g. for improving device’s battery life at times when location data is unlikely to change. By default automatic pausing of location updates is allowed.
Declaration
Swift
func setPauseLocationUpdatesAutomatically(allowed: Bool) -> LocationEngineStatusParameters
allowedSet to
trueto allow automatic pausing of location updates, orfalseto disable them.Return Value
LocationEngineStatus.okif call succeeds.LocationEngineStatus.notSupportedon platforms which do not support automatic pausing of location updates. -
Check if automatic pausing of location updates are enabled. Returns
falseon platforms which do not support controlling of automatic pausing of location updates usingsetPauseLocationUpdatesAutomatically(...)method.Declaration
Swift
func getPauseLocationUpdatesAutomatically() -> BoolReturn Value
Trueif automatic pausing of location updates is enabled,falseotherwise.