CBPeripheralManager objects are used to manage published services within the local peripheral device’s Generic Attribute Profile (GATT) database and to advertise these services to central devices (represented by CBCentral objects). While a service is in the database, it is visible to, and can be accessed by, any connected central. That said, if your app has not specified the bluetooth-peripheral background mode, the contents of its services become disabled when it is in the background or in a suspended state; any remote central trying to access the service’s characteristic value or characteristic descriptors receives an error.


class CBPeripheralManager : CBManager


Before you call CBPeripheralManager methods, the state of the peripheral manager object must be powered on, as indicated by the CBPeripheralManagerState.poweredOn. This state indicates that the peripheral device (your iPhone or iPad, for instance) supports Bluetooth low energy and that its Bluetooth is on and available to use.


Initializing a Peripheral Manager

init(delegate: CBPeripheralManagerDelegate?, queue: DispatchQueue?)

Initializes the peripheral manager with a specified delegate and dispatch queue.

init(delegate: CBPeripheralManagerDelegate?, queue: DispatchQueue?, options: [String : Any]?)

Initializes the peripheral manager with specified delegate, dispatch queue, and initialization options.

var delegate: CBPeripheralManagerDelegate?

The delegate object specified to receive peripheral events.

Monitoring the State of a Peripheral Manager

class func authorizationStatus() -> CBPeripheralManagerAuthorizationStatus

Returns the app’s authorization status for sharing data while in the background state.


Adding and Removing Services

func add(CBMutableService)

Publishes a service and any of its associated characteristics and characteristic descriptors to the local GATT database.

func remove(CBMutableService)

Removes a specified published service from the local GATT database.

func removeAllServices()

Removes all published services from the local GATT database.

Managing Advertising

func startAdvertising([String : Any]?)

Advertises peripheral manager data.

func stopAdvertising()

Stops advertising peripheral manager data.

var isAdvertising: Bool

A Boolean value indicating whether the peripheral is currently advertising data.

Sending Updates of a Characteristic’s Value

func updateValue(Data, for: CBMutableCharacteristic, onSubscribedCentrals: [CBCentral]?) -> Bool

Sends an updated characteristic value to one or more subscribed centrals, via a notification or indication.

Responding to Read and Write Requests

func respond(to: CBATTRequest, withResult: CBATTError.Code)

Responds to a read or write request from a connected central.

Setting Connection Latency

func setDesiredConnectionLatency(CBPeripheralManagerConnectionLatency, for: CBCentral)

Sets the desired connection latency for an existing connection to a central device.


enum CBPeripheralManagerState

Values representing the current state of the peripheral manager.

enum CBPeripheralManagerConnectionLatency

Values representing the connection latency of the peripheral manager.

enum CBPeripheralManagerAuthorizationStatus

Values representing the current authorization state of the peripheral manager.




Inherits From

Conforms To

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software