Official Content

How to start  monitoring some specific beacon region?

Beacons.AddBeaconProximityAlert(proximityAlert)

Where
proximityAlert is a BeaconProximityAlert SDT. The AddBeaconProximityAlert method receives this SDT and add the alert or replace if a region with the same identifier is found.

This can also be done with a collection of BeaconProximityAlert SDT and the AddBeaconProximityAlerts method.


I'm inside a Beacon region now what?

After you know you are in a Beacon region you can give your users further information (navigation, etc) by determinating the distance between a device and a Beacon.
For example when people enter to a conference you can give a Welcome information by using the previous API of proximity of a Beacon region, but after this welcome information you know people is in, so you can guide them to navigate the conference by start ranging all the beacons that are inside the conference in different rooms.

In order to start ranging you need to call 

Beacons.StartRangingBeaconRegion(BeaconRegion)

Where
BeaconRegion is a BeaconRegion SDT and the StartRangingBeaconRegion method starts the delivery of notifications for beacons in the specified region.


How to know when entering or exiting to a BeaconRegion?

There are some events on the Beacons external object that you can listen to do this.

EnterBeaconRegion

Event Beacons.EnterBeaconRegion(BeaconRegion)

Invoked when the user enters a monitered beacon region

ExitBeaconRegion

Event Beacons.ExitBeaconRegion(BeaconRegion)

Invoked when the user exits a monitored beacon region

ChangeBeaconsInRange

Event Beacons.ChangeBeaconsInRange(BeaconRegion, Beacons)

Invoked when a new set of beacons' states are available in the specified region.

The first two events are fired for proximityAlerts being added previously, the third one, is called periodicaly with beacons states updates for regions started ranging previously.


Let your device be a Beacon

As explained in What is a Beacon? any device with at least Bluetooth 4.0 is potencially a Beacon.

GeneXus provides a method in Beacons to allow your device (if allowed) became ranging as a Beacon.

Beacons.StartAsBeacon(BeaconInfo)

BeaconInfo is based on the BeaconInfo Data Type and contains the beacon information to advertise.

In order to stop advertising the current device as a beacon use

Beacons.StopAsBeacon()

Additional Functions

Beacons.GetBeaconProximityAlerts()

Retrieve a collection for the beacon regions that are currently being monitored. See more

Beacons.RemoveBeaconProximityAlert(proximityAlertRegionId)

Remove the region being monitored by identifier. See more

Beacons.ClearBeaconProximityAlerts()

Removes all the beacon regions being monitored. See more

Beacons.GetBeaconRegionState(regionId)

Retrieve the cached state of the specified beacon region. See more

Beacons.StopRagingBeaconRegion(regionId)

Stops the delivery of notifications for the specified beacon region. See more

Beacons.GetRangedBeaconRegions()

Retrieve a collection for the beacon regions thar are currently providing ranging. See more

Beacons.GetBeaconsInRange(regionId)

Retrieve a collection for the beacons (sorted by proximity) currently in range for the given region. Empty regionId means all regions. See more


See also

Beacons external object





Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant