DefaultCLLocationProvider
public class DefaultCLLocationProvider : NSObject, ValidatingLocationProvider
Implementation of LocationProvider
that uses CLLocationManager
as a GPS source provider.
Provides location updates and manages location-related services.
This class is responsible for providing GPS location updates using the CLLocationManager
.
The class includes:
- enable location and disable location updates
- manage observers and
validate location updates.
Important
This is a Public Preview API. It may be changed or removed at any time.
-
DefaultCLLocationProvider convenience initializer. Initializes the provider with an optional location validation policy.
This initializer allows the creation of a
DefaultCLLocationProvider
instance with a custom location validation policy. If no custom policy is provided, a default validation policy is used.Declaration
Swift
convenience public init( locationValidationPolicy: LocationUpdateValidator? = nil )
Parameters
locationValidationPolicy
Policy for validating incoming location updates, defined by
LocationUpdateValidator
protocol. Default isnil
.
-
The last known location provided by the
CLLocationManager
.Declaration
Swift
public var lastKnownLocation: GeoLocation?
-
Policy for validating incoming location updates.
Declaration
Swift
public var validationPolicy: LocationUpdateValidator
-
Starts the process of updating locations and headings.
This method starts the
CLLocationManager
to begin receiving location and heading updates. It checks the authorization status and starts the updates only if authorized. The last known location is used, if available.Declaration
Swift
public func enable()
-
Stops the process of updating locations and headings.
This method stops the
CLLocationManager
from receiving location and heading updates. It sets therunning
flag tofalse
.Declaration
Swift
public func disable()
-
Add an observer to receive location update notifications.
Declaration
Swift
public func addObserver(_ observer: LocationUpdateObserver)
Parameters
observer
The observer to be added.
-
Remove an observer from receiving location update notifications.
Declaration
Swift
public func removeObserver(_ observer: LocationUpdateObserver)
Parameters
observer
The observer to be removed.