Scans for peripherals that are advertising services.
SDKs
- iOS 5.0+
- macOS 10.7+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 4.0+
Framework
- Core Bluetooth
Declaration
Parameters
serviceUUIDs
options
A dictionary of options for customizing the scan. For available options, see Peripheral Scanning Options.
Discussion
You can provide an array of CBUUID
objects — representing service UUIDs — in the service
parameter. When you do, the central manager returns only peripherals that advertise the services you specify. If the service
parameter is nil
, this method returns all discovered peripherals, regardless of their supported services.
Note
The recommended practice is to populate the service
parameter rather than leaving it nil
.
If the central manager is actively scanning with one set of parameters and it receives another set to scan, the new parameters override the previous set. When the central manager discovers a peripheral, it calls the central
method of its delegate object.
Your app can scan for Bluetooth devices in the background by specifying the bluetooth-central
background mode. To do this, your app must explicitly scan for one or more services by specifying them in the service
parameter. The CBCentral
scan option has no effect while scanning in the background.