Instance Method


Scans for peripherals that are advertising services.


func scanForPeripherals(withServices serviceUUIDs: [CBUUID]?, options: [String : Any]? = nil)



An array of CBUUID objects that the app is interested in. In this case, each CBUUID object represents the UUID of a service that a peripheral is advertising.


An optional dictionary specifying options to customize the scan. For available options, see Peripheral Scanning Options.


You can provide an array of CBUUID objects—representing service UUIDs—in the serviceUUIDs parameter. When you do, the central manager returns only peripherals that advertise the services you specify (recommended). If the serviceUUIDs parameter is nil, all discovered peripherals are returned regardless of their supported services (not recommended). If the central manager is already scanning with different parameters, the provided parameters replace them. When the central manager object discovers a peripheral, it calls the centralManager(_:didDiscover:advertisementData:rssi:) method of its delegate object.

Apps that have specified the bluetooth-central background mode are allowed to scan while in the background. That said, they must explicitly scan for one or more services by specifying them in the serviceUUIDs parameter. The CBCentralManager scan option is ignored while scanning in the background.

See Also

Scanning or Stopping Scans of Peripherals

func stopScan()

Asks the central manager to stop scanning for peripherals.