I want to monitor a range of beacons using Estimote. For example lets say that ("rid", "uuid", , ) identifies a series of beacons, where all the beacons my app uses share the same "rid" and "uuid". I also hace a number of brands, where each can have more than one store.
This app would be sold to a number of brands, and I would like to use something like this:
private static final Region ALL_STORES_REGION = new Region("rid", "uuid", BRAND_ID, null);
beaconManager.startMonitoring(ALL_STORES_REGION);
Then, to receive notifications when a customer exits a certain store:
beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
@Override
public void onEnteredRegion(Region region, List<Beacon> beacons) {
// do nothing
}
@Override
public void onExitedRegion(Region region) {
listener.onCustomerLeaving(region.getMinor());
}
});
This is what Im using right now, and its working fine. The problem is that since I used a null as the last value in the Region (in order to capture any store of that brand), the region returned by the onEnteredRegion method returns null, and Im unable to identify the specific store.
I thought of two possible solutions: Saving the list of beacons return on the entering, and retrieving the store's id when the customer leaves. (This could be dangerous, if there are more than one beacon in range)
Or, monitoring a number of specific Regions using the store ids. (This would involve knowing all the stores Ids, so again not an ideal solution)
I was wandering if there was any way to get the actual Beacon that triggered the onExitedRegion method, or any other better solution.
Thanks!
You have two options:
Start ranging when you receive onEnteredRegion callback. From ranging you get back beacons around you so you can identify a store/brand.
Take a look at second parameter (beacon) in onEnteredRegion. According to docs:
beacons - List of beacons that triggered onEnteredRegion event. This list may not reflect all beacons around that are matching given region.
You can use this information to identify store/brand.