GeofenceManager
open class GeofenceManager : NSObject
extension GeofenceManager: CLLocationManagerDelegate
A singleton object that is responsible for handling geofence related data and events
-
The native
CLLocationManager
Declaration
Swift
public private(set) var manager: CLLocationManager!
-
Listener for
LocationManager.notificationName
eventDeclaration
Swift
open var locationEventListener: NSObjectProtocol?
-
The associated
GeofenceClientEvents
that handles client eventsDeclaration
Swift
public var clientEventsManager: GeofenceClientEvents?
-
The last known location returned by
LocationManager
Declaration
Swift
public private(set) var lastKnownLocation: CLLocation?
-
Singleton property
Declaration
Swift
public static let shared: GeofenceManager
-
A boolean flag that returns the value of
Configuration.shared.isGeofencingEnabled
Declaration
Swift
open var isGeofencingEnabled: Bool { get }
-
A boolean flag that indicates whether the location services and geofencing is allowed
Declaration
Swift
open var isLocationServicesAndGeofencingEnabled: Bool { get }
-
Starts the
GeofenceManager
- validates the value ofisGeofencingEnabled
, adds listener forLocationManager.notificationName
, event callsLocationManager.shared.checkAndRequestAuthorizationIfNeeded()
, and listens for location updates, then will create regions based on the returned locationDeclaration
Swift
open func start()
-
Stops the
GeofenceManager
- validates the value ofisGeofencingEnabled
, callsLocationManager.shared.stopReceivingLocationUpdates()
, removes listener forLocationManager.notificationName
eventDeclaration
Swift
open func stop()
-
Calls
stopMonitoring
for each monitoredCLRegion
Declaration
Swift
open func stopMonitoringAllRegions()
-
Resets the radius of the monitored
CLRegion
Declaration
Swift
open func updateThresholdRegion(radius: CLLocationDistance)
-
Updates monitored regions based on the given
[Place]
, monitors only up to 19 regionsDeclaration
Swift
open func updateMonitoredRegions(places: [GeofencePlace])
-
Adds an event listener for
LocationManager.notificationName
eventDeclaration
Swift
open func addEventListener()
-
Removes an event listener for
LocationManager.notificationName
eventDeclaration
Swift
open func removeEventListener()
-
Triggers a
GeofenceClientEvents.tiggerClientEvent(in: CLRegion, event: Place.ClientEventType)
given thatLocationManager.shared.isAuthorized
andGeofenceManager.isGeofencingEnabled
are both trueDeclaration
Swift
public func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion)
-
Triggers a
GeofenceClientEvents.tiggerClientEvent(in: CLRegion, event: Place.ClientEventType)
given thatLocationManager.shared.isAuthorized
azndGeofenceManager.isGeofencingEnabled
are both trueDeclaration
Swift
public func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion)