iBeacon monitoring

I tried to use the provided example to monitor some iBeacons; however the code seems to be generating a random UUID and not using the designed string (proximityUUID). The code

beaconRegion = new CLBeaconRegion(new NSUUID(proximityUUID), 1, 1, beaconID);

seems to generate a new UUID instead of using the one specified by the code. In fact, monitoring beaconRegion from Xcode with

Debug.Log("BEACON REGION " + beaconRegion);

gives different results every time it’s called upon…

BEACON REGION [CLBeaconRegion: Uuid=C6F1C598-58D5-4C4E-8C74-360D56618CFC]
BEACON REGION [CLBeaconRegion: Uuid=EFCDED59-D111-46D8-B997-89FCFBF76DFF]

etc. which are all different from the beacon specified in the code and I’m supposed to monitor…

Question is: how do you monitor the beacon whose UUID is assigned to the string proximityUUID ?

Hi, the “Uuid” printed out in the CLBeaconRegion is not the NSUUID passed into the constructor. We use the “Uuid” as an internal way to identify native objects from Unity. You can safely ignore the “Uuid” printed out there. If you want to get the NSUUID passed in to the constructor, you can use beaconRegion.proximityUUID.UUIDString().

To monitor a beacon, you would use the same CLBeaconRegion. If you look at the example code, the same CLBeaconRegion is used in both the advertising and monitoring code.

Hope this clarifies it.