---
title: "scanForPeripherals(withServices:options:)"
framework: corebluetooth
role: symbol
role_heading: Instance Method
path: "corebluetooth/cbcentralmanager/scanforperipherals(withservices:options:)"
---

# scanForPeripherals(withServices:options:)

Scans for peripherals that are advertising services.

## Declaration

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

## Parameters

- `serviceUUIDs`: An array of doc://com.apple.corebluetooth/documentation/CoreBluetooth/CBUUID objects that the app is interested in. Each doc://com.apple.corebluetooth/documentation/CoreBluetooth/CBUUID object represents the UUID of a service that a peripheral advertises.
- `options`: A dictionary of options for customizing the scan. For available options, see doc://com.apple.corebluetooth/documentation/CoreBluetooth/peripheral-scanning-options.

## Discussion

Discussion 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. If the serviceUUIDs parameter is nil, this method returns all discovered peripherals, regardless of their supported services. note: The recommended practice is to populate the serviceUUIDs 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 centralManager(_:didDiscover:advertisementData:rssi:) 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 serviceUUIDs parameter. The CBCentralManager scan option has no effect while scanning in the background.

## See Also

### Scanning or Stopping Scans of Peripherals

- [Peripheral Scanning Options](corebluetooth/peripheral-scanning-options.md)
- [stopScan()](corebluetooth/cbcentralmanager/stopscan().md)
- [isScanning](corebluetooth/cbcentralmanager/isscanning.md)
