Class

CLBeaconRegion

A 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.

Overview

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:

  • The proximityUUID property 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.

  • The major property 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.

  • The minor property 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.

Symbols

Initializing the Beacon Region

init(proximityUUID: UUID, identifier: String)

Initializes and returns a region object that targets a beacon with the specified proximity ID.

init(proximityUUID: UUID, major: CLBeaconMajorValue, identifier: String)

Initializes and returns a region object that targets a beacon with the specified proximity ID and major value.

init(proximityUUID: UUID, major: CLBeaconMajorValue, minor: CLBeaconMinorValue, identifier: String)

Initializes and returns a region object that targets a beacon with the specified proximity ID, major value, and minor value.

Accessing the Beacon Attributes

var proximityUUID: UUID

The unique ID of the beacons being targeted.

var major: NSNumber?

The value identifying a group of beacons.

var minor: NSNumber?

The value identifying a specific beacon within a group.

Delivering Beacon Notifications

var notifyEntryStateOnDisplay: Bool

A Boolean indicating whether beacon notifications are sent when the device’s display is on.

Getting Beacon Advertisement Data

func peripheralData(withMeasuredPower: NSNumber?)

Retrieves data that can be used to advertise the current device as a beacon.

Constants

CLBeaconMajorValue

The most significant value in a beacon.

CLBeaconMinorValue

The least significant value in a beacon.

Relationships

Inherits From