Yes, you can continue to process BLE events in the background if you enable the Bluetooth function in the background. Just select your main project file, then select the target and the “Features” tab, turn on the background and turn on “Use Bluetooth LE Accessories”.
In the main application, you will have the opportunity to handle any BLE events, even if the application is in the background.
It should be noted that BLE events trigger an action, so be sure to put the code that you want to execute in the background inside the delegate method, for example didUpdateValueForCharacteristic .
Your code will be executed depending on your queue when you initialized the CBCentralManager .
The widget and application cannot use the BLE connection. You can communicate between the application and widgets using the methods that Apple offers (NSUserDefaults or monitoring key values), or you can create another BLE connection from the widget and exchange data through it.
source share