currently I’m working with iBeacons and by far have managed to scan and display them on screen. But then I was told to scan and display for ONLY the nearest one ( the closest one), and ignore all the others. Can someone give me a rough idea how to get the closest beacon among a bunch of beacons that I have?
I believe that I can’t use the Proximity and Accuracy in this case since they often fluctuate.
Basically I haven't figured out how to work with the logic:
onBeaconsDiscovered() {
this.delegate.didRangeBeaconsInRegion().subscribe( data => {
if (data.beacons !== null) {
let nearestBeacon = // { code for detecting the nearest beacon }
// then show up a notification / alert / toast ...
}
});
}
Please help! I appreciate every idea.