Class

CLBeaconRegion

A region used to detect the presence of iBeacon devices.

Declaration

class CLBeaconRegion : CLRegion

Overview

A CLBeaconRegion object defines a region that you use to detect Bluetooth beacons conforming to the iBeacon specification. Whereas a CLCircularRegion is centered on a geographic location, a CLBeaconRegion is focused on an iBeacon with specific identifying characteristics, 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 Device.

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

Topics

Initializing the Beacon Region

init(beaconIdentityConstraint: CLBeaconIdentityConstraint, identifier: String)

Initializes and returns a region object that targets beacons that satisfy the specified beacon identity constraints.

init(uuid: UUID, identifier: String)

Initializes and returns a region object that targets beacons with the specified UUID.

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

Initializes and returns a region object that targets beacons with the specified UUID and major value.

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

Initializes and returns a region object that targets beacons with the specified UUID, major, and minor values.

init(proximityUUID: UUID, identifier: String)

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

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

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

Deprecated

Accessing the Beacon Region Attributes

var uuid: UUID

The UUID value from the beacon identity constraint that defines the beacon region.

var major: NSNumber?

The major value from the beacon identity constraint that defines the beacon region.

var minor: NSNumber?

The minor value from the beacon identity constraint that defines the beacon region.

var beaconIdentityConstraint: CLBeaconIdentityConstraint

The beacon identity constraint that defines the beacon region.

var proximityUUID: UUID

The unique ID of the beacons being targeted.

Deprecated

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?) -> NSMutableDictionary

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

Conforms To

See Also

iBeacon

Ranging for Beacons

Detect that the device is in a beacon region, then use ranging to find the beacons within the region.

Determining the Proximity to an iBeacon Device

Detect beacons and determine the relative distance to them.

Turning an iOS Device into an iBeacon Device

Broadcast iBeacon signals from an iOS device.

class CLBeacon

Information about an observed iBeacon device and its relative distance to the user’s device.

class CLBeaconIdentityConstraint

Identity characteristics that can match one or more beacons.