CLBeaconRegion object defines a type of region that is based on the device’s proximity to a Bluetooth beacon, as opposed to a geographic location. A beacon region looks for devices whose identifying information matches the information you provide. When that device comes in range, the region triggers the delivery of an appropriate notification.
- iOS 7.0+
You can monitor beacon regions in two ways. To receive notifications when a device enters or exits the vicinity of a beacon, use the
startMonitoring(for:) method of your location manager object. While a beacon is in range, you can also call the
startRangingBeacons(in:) method to begin receiving notifications when the relative distance to the beacon changes.
If you want to configure the current iOS device as a Bluetooth beacon, create a beacon region with the appropriate identifying information. You can then call the
peripheralData(withMeasuredPower:) method of the region to get a dictionary that you can use to advertise the device with the Core Bluetooth framework. For more information about using that framework to advertise the device as a beacon, see Location and Maps Programming Guide.
Specifying a Beacon’s Identity
You identify beacons using a combination of three values:
proximityUUIDproperty contains the identifier that you use to identify your company’s beacons. You typically generate only one UUID for your company’s beacons but can generate more as needed. You generate this value using the uuidgen command-line tool.
majorproperty contains a value that can be used to group related sets of beacons. For example, a department store might assign the same major value for all of the beacons on the same floor.
minorproperty specifies the individual beacon within a group. For example, for a group of beacons on the same floor of a department store, this value might be assigned to a beacon in a particular section.
You program the identity values into the beacon hardware itself using the tools provided by the beacon manufacturer. In your app, you then use those values to identify which beacon was found and respond appropriately.