BeaconMonitor
public class BeaconMonitor : NSObject
BeaconMonitor is used to monitor nearby beacons.
Once a beacon is detected, Usher SDK will make a call to Usher Server to execute the beacon action, which is defined on the network. To use beacon monitoring, always location access
is required. The beacon action request is only sent to server if the device is in the defined geo-fences.
-
Singleton
Declaration
Swift
public static let instance: BeaconMonitor
-
A Publisher that can be subscribed to get the latest set of BeaconRegion.
Declaration
Swift
public static var nearbyRegionPublisher: ReplaySubject<Set<BeaconRegion>> { get }
-
Start Monitoring all the beacons with option rangingOnly or not
Monitoring beacons will trigger enter and exit beacon region actions. Ranging beacons will trigger ranging beacons action, that will return a list of beacons in range.
Declaration
Swift
public class func start(rangingOnly: Bool = false)
Parameters
rangingOnly
if true, only range beacons. Otherwise, monitor beacons.
-
Stop Monitoring all the beacons.
Declaration
Swift
public class func stop()
-
Get monitored Region with BeaconRegion’s unique id
Declaration
Swift
public class func monitoredRegionWithId(uniqueId: String) -> BeaconRegion?
-
Setup BeaconMonitor: Begin ranging or monitoring all BeaconRegions
Declaration
Swift
public func setup()
-
Start ranging or monitoring all BeaconRegions for one badge
Declaration
Swift
public func startMonitoring(for badgeId: String)
Parameters
badgeId
Use badgeId to find all BeaconRegions belong to the badge
-
Stop ranging or monitoring all BeaconRegions for one badge
Declaration
Swift
public func stopMonitoring(for badgeId: String)
Parameters
badgeId
Use badgeId to find all BeaconRegions belong to the badge
-
Get BeaconRegion by unique beaconId
Declaration
Swift
public func beaconRegion(by beaconId: String) -> BeaconRegion?
Parameters
beaconId
unique id for BeaconRegion
Return Value
existed BeaconRegion or nil