---
title: "centralManager(_:willRestoreState:)"
framework: corebluetooth
role: symbol
role_heading: Instance Method
path: "corebluetooth/cbcentralmanagerdelegate/centralmanager(_:willrestorestate:)"
---

# centralManager(_:willRestoreState:)

Tells the delegate the system is about to restore the central manager.

## Declaration

```swift
optional func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any])
```

## Parameters

- `central`: The central manager that provides this information.
- `dict`: A dictionary that contains information about the central manager that the system preserved when your app stopped. For the available keys, see doc://com.apple.corebluetooth/documentation/CoreBluetooth/central-manager-state-restoration-options.

## Discussion

Discussion This method only applies to your app if it opts in to state restoration by providing CBCentralManagerOptionRestoreIdentifierKey when initializing a CBCentralManager. The system invokes this method when relaunching your app to service active or pending connections and scans that were in progress when your app stopped. If the system calls this method but the parameters are missing (for example, if your app stopped before establishing peripherals and services), your app is responsible for restoring its previous state. Initialize any peripherals and services your app requires, and resume any activities from where they stopped. func centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any]) {     if let peripherals = dict[CBCentralManagerRestoredStatePeripheralsKey] as? [CBPeripheral] {         // Use the restored peripherals.     } else {         // Reconnect to known devices, for example from `UserDefaults`.     }

if let services = dict[CBCentralManagerRestoredStateScanServicesKey] as? [CBUUID] {         // Resume scanning for the restored services.     } else {         // Start scanning with your default services.         let heartRateService = CBUUID(string: "180D")         central.scanForPeripherals(withServices: [heartRateService])     } }

## See Also

### Monitoring the Central Manager’s State

- [centralManagerDidUpdateState(_:)](corebluetooth/cbcentralmanagerdelegate/centralmanagerdidupdatestate(_:).md)
