3

My question is "how do I go about reconnecting to a ble device once the app is not in the foreground"? I've done my research and it seems that the best way to connect to a paired ble device is through retrivePeripherals:UUID. Once it finds something the didRetivePeripherials is called back and here I can try to reconnect to the device again. I can't seem to be able to do this while the app is running on the background.

Help is appreciated.

Andresn N.

Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247

1 Answers1

1
  1. Enable the bluetooth-central background mode
  2. Use the CBCentralManagerOptionRestoreIdentifierKey option supplying a unique identifier when instantiating your CBCentralManager
  3. Implement the - (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)state delegate method
    3.1 Get an array of restorable peripherals using NSArray *peripherals = state[CBCentralManagerRestoredStatePeripheralsKey]
    3.2 Call the connectPeripheral method of your CBCentralManager supplying each peripheral to restore

Read more of the details in the Core Bluetooth Programming Guide

Yazid
  • 970
  • 7
  • 14