Class

CLBeaconRegion

A region used to detect iBeacon hardware.

Overview

A CLBeaconRegion object defines a region that you use to detect Bluetooth beacons. Whereas a CLCircularRegion is centered on a geographic location, a CLBeaconRegion is centered on an iBeacon with specific identifying information, which you provide. When a matching device comes in range, Core Location notifies your app.

You monitor beacon regions in two ways. To detect when a beacon is in range, use the startMonitoring(for:) method of your location manager object. After detecting a beacon, call the startRangingBeacons(in:) method to determine the relative distance to that beacon.

When detecting an iBeacon, you must specify the proximityUUID, major, and minor values that you programmed into the beacon hardware. You use the values to identify your beacons uniquely and you can specify a subset of values to detect multiple beacons. The proximityUUID property is typically the same for all of the beacons in your installation. Use the major and minor values to distinguish among different beacons in your installation.

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 Turning an iOS Device into an iBeacon.

For information about how to detect beacons, see Determining the Proximity to an iBeacon.

Topics

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 value 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

typealias CLBeaconMajorValue

The most significant value in a beacon.

typealias CLBeaconMinorValue

The least significant value in a beacon.

Relationships

Inherits From

See Also

iBeacon

Determining the Proximity to an iBeacon

Learn how to detect beacons and determine the relative distance to them.

Turning an iOS Device into an iBeacon

Learn how to broadcast iBeacon signals from an iOS device.

class CLBeacon

Information about a detected iBeacon and the relative distance to it.