MASTG-KNOW-0130: Core Bluetooth
Core Bluetooth is the iOS framework for Bluetooth Low Energy (BLE) communication. Apps use it to discover, connect to, and exchange data with BLE peripherals, such as fitness trackers, medical sensors, smart home hardware, and companion devices.
APIs¶
Apps interact with BLE primarily through two manager classes:
CBCentralManager: Scans for, discovers, and connects to BLE peripherals. After connecting, the app reads, writes, and subscribes to GATT characteristics to exchange data.CBPeripheralManager: Lets the local device act as a BLE peripheral by advertising, publishing GATT services and characteristics, and responding to read, write, and subscription requests from connected centrals.
Data is exchanged through GATT services and characteristics. Characteristics can support operations such as read, write, notify, and indicate, depending on how the peripheral defines them.
Permissions¶
Apps linked on or after iOS 13 must declare NSBluetoothAlwaysUsageDescription in Info.plist. The system presents a permission prompt when the app first attempts to use Bluetooth.
For older apps, NSBluetoothPeripheralUsageDescription was used on iOS 6 through iOS 13.
Background Bluetooth use requires the UIBackgroundModes key with bluetooth-central or bluetooth-peripheral, depending on the app's role. Background scanning and advertising are subject to additional system restrictions.