iBeacon's major/minor is not detected unless it's specified in the region's settings

aga :

The question I'm struggling with is fairly simple - I know the uuids of the iBeacons I'm using, but the major/minor parameters are not preset, i.e. they might change dynamically. What I want to achieve is to be able to get the current values of major/minor when the BeaconManager invokes the MonitorNotifier's methods. For some reason, it does not pass the major/minor in MonitorNotifier if the Region was constructed only with uuids, for example like this:

val region = Region(uuid.toString(), Identifier.fromUuid(uuid));

I talked to the iOS developer who works with iBeacon via native iOS APIs and he says the behaviour is exactly the same on iOS - the major/minor are not provided via monitoring, unless he specifies the exact values to search for.

The major/minor can be detected by ranging, but there're reasons of why I want to keep using monitoring instead (without diving too deep into the details - it's much easier to work with didEnter, didExit and didDetermineStateForRegion methods).

Is there something I might be missing?

davidgyoung :

Your description of how beacon monitoring APIs work is accurate. It is the same on both iOS CoreLocation as with the Android Beacon Library.

I am the one who designed this API on the Android Beacon Library. It works this way because I wanted it to be easy to build cross platform apps, so I made it the same as iOS.

The reason that iOS works this way is because Apple modelled it on their pre-existing Geofence Region API, which also tells you when you entered or exited but does not give you more details about specifics causing the entry or exit.

You can certainly argue whether or not a different API would be better. Unfortunately, when using a SDK, you must accept the APIs as they are. The alternative is to build your own.

If you really want an event callback for a specific beacon detected / beacon no longer detected events, you can easily build this on top of Ranging APIs. Simply track a list of all beacons visible, and when a new one is found, fire a didStertDetectingBeacon event. Then if 10 seconds passes without seeing it in a ranging callback, fire a didStopDetectingBeacon callback.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=175136&siteId=1