BeaconsModule Class
Item Index
Methods
Properties
Constants
Methods
clearAppLaunchIntent
()
Void
Use this function to instruct the module not to launch the app when the user enters a monitored region.
Returns:
createBeaconRegion
-
params
Creates a BeaconRegion object that can be used to start advertising an iBeacon.
Parameters:
-
params
ObjectAn object with the following properties (see the properties of the BeaconRegion class for details):
-
identifier
StringA unique identifier to associate with the returned region object. You use this identifier to differentiate regions within your application.
-
UUID
StringThe UUID of the beacon.
-
[major]
Number optionalThe major number of the beacon. If not specified, the major and minor numbers of the beacon are ignored.
-
[minor]
Number optionalThe minor number of the beacon. If not specified, the minor number of the beacon is ignored.
-
[notifyEntryStateOnDisplay=false]
Boolean optionalWhen set to
true
, the beacon notifications will be sent only when the user turns on the display and the device is already inside the region.
-
Returns:
disable
()
Boolean
Disables the Bluetooth adapter.
Returns:
Returns true
if the Bluetooth adapter
was successfully disabled.
enable
()
Boolean
Enables the Bluetooth adapter.
Returns:
Returns true
if the Bluetooth adapter
was successfully enabled.
getState
()
Number
Returns the current state of the local Bluetooth adapter.
See also the STATE_OFF, STATE_ON, STATE_TURNING_OFF, and STATE_TURNING_ON constants.
Returns:
isAppLaunchConfigured
()
Boolean
Determines whether the module is currently configured to launch the app when BLE activity is detected.
Returns:
isEnabled
()
Boolean
Determines whether the Bluetooth adapter is enabled and ready for use.
Returns:
Returns true
if Bluetooth is currently
enabled.
isSupported
()
Boolean
Determines whether the device is capable of communicating with other devices via Bluetooth Low Energy radio.
Returns:
requestRegionState
-
params
Retrieves the state of a region asynchronously.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
retrieveMonitoredRegions
()
Void
Retrieves the currently monitored beacon regions.
Async function; returns the results in a retrievedMonitoredRegions event.
Returns:
setAppLaunchIntent
-
params
Specifies the parameters for the intent the module is expected to use to launch the app. Use this function to instruct the module to launch the app when the user enters a monitored region.
The intent launching the app will have an extra called eventName
,
which is a string holding the name of the event that caused the module
to launch the app.
Parameters:
-
params
Object-
packageName
StringThe package name of the app to be launched by the module.
-
className
StringThe name of the class (typically the app's main activity) to be launched by the module.
-
Returns:
setScanTimers
-
params
Use this function to control the timing of beacon related scanning. By default, scanning is restarted every 1.1 seconds while region monitoring or beacon ranging is enabled, to be able to provide beacon related events in a timely manner. You can use this function to increase the scan interval if less frequent beacon related events are sufficient for your use case.
Note that these timers don't impact general scanning unless general scanning is used in parallel with beacon related functionality. See the Beacon Support section of the Readme for more information.
Calling this function will reset scanning to make sure the new timers take effect immediately.
Parameters:
-
params
Object-
scanPeriod
NumberScan period in milliseconds. This is how long each scanning session lasts.
-
scanPausePeriod
NumberScan pause period in milliseconds. This is the time gap between scan periods.
-
Returns:
startRangingBeacons
-
params
Starts the delivery of notifications for beacons in the specified region.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
startRegionMonitoring
-
params
Starts monitoring the specified region.
You must call this method once for each region you want to monitor. If an existing region with the same identifier is already being monitored by the application, the old region is replaced by the new one. If that old region was being ranged, then so will the new one. Note that "identifier" literally means the identifier property, not the UUID! The regions you add using this method are stored in the monitoredRegions property.
Parameters:
-
params
ObjectAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
stopRangingBeacons
-
[params]
Stops the delivery of notifications for beacons in the specified region. If no beacon region is specified, then it stops ranging for all regions.
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
stopRegionMonitoring
-
[params]
Stops the delivery of notifications for beacons in the specified region. If no beacon region is specified, then it stops ranging for all regions. Note that the region is being identified by its identifier property, not the UUID!
Parameters:
-
[params]
Object optionalAn object with the following properties:
-
beaconRegion
BeaconRegionThe region of interest.
-
Returns:
Properties
filterDuplicateBeacons
Boolean
Determines whether the beacons included with the
rangedBeacons
event will be filtered for duplicates. Defaults to false
.
A beacon is considered a duplicate of another if their UUID, major, and
minor numbers are all the same.
monitoredRegions
Array of BeaconRegions
read-only
The beacon regions currently being monitored by the module.
rangedRegions
Array of BeaconRegions
read-only
The beacon regions currently being ranged by the module.
state
Number
read-only
The current state of the local Bluetooth adapter.
See also the STATE_OFF, STATE_ON, STATE_TURNING_OFF, and STATE_TURNING_ON constants.
Constants
REGION_STATE_INSIDE
Number
One of the possible values of the state
property of the
regionStateUpdated event.
REGION_STATE_OUTSIDE
Number
One of the possible values of the state
property of the
regionStateUpdated event.
REGION_STATE_UNKNOWN
Number
One of the possible values of the state
property of the
regionStateUpdated event.
Events
enteredRegion
This event is fired when the user enters a monitored region.
Event Payload:
-
region
BeaconRegionThe region in question.
exitedRegion
This event is fired when the user exits a monitored region.
Event Payload:
-
region
BeaconRegionThe region in question.
moduleReady
This event is fired when the module is ready. Wait for this event before calling any methods on the module.
rangedBeacons
Use this event to determine which beacons are in range.
See also the filterDuplicateBeacons property.
Event Payload:
-
beacons
Array of BeaconsAn array of Beacon objects representing the beacons currently in range. You can use the information in these objects to determine the range of each beacon and its identifying information.
-
region
BeaconRegionThe region object containing the parameters that were used to locate the beacons.
regionStateUpdated
This event is fired when the state of a monitored region is updated.
Event Payload:
-
region
BeaconRegionThe region object containing the parameters that were used to locate the beacons.
-
state
NumberOne of the REGION_STATE_* constants.
retrievedMonitoredRegions
Returns the result of the retrieveMonitoredRegions function.
Event Payload:
-
beaconRegions
Array of BeaconRegionsAn array of BeaconRegion objects, representing the currently monitored beacon regions.