I'm working with a Bluetooth peripheral that after connecting to it there is a ACK back and forth before it actually can send me the data that I need.
The flow is like this:
- Discover the peripheral
- Connect to the peripheral
- Discover services and characteristics
- Listen for updates on a specific characteristic
- Peripheral sends a special message to this characteristic
- The app then sends an ACK to the peripheral
- The peripheral sends me the data needed by the app
I have implemented the needed logic in the protocol method for State Preservation and Restoration centralManager(_ central: CBCentralManager, willRestoreState dict: [String : Any])
Question 1:
When the app is in the background and iOS decides to take over the Bluetooth communication (for resource reasons), how will iOS manage to do steps 5, 6 and 7?
Because if it can't then the peripheral won't be able to send the data that the app needs in step 7.
Question 2:
In the docs I read that iOS might start your app for a few seconds. Will the viewDidLoad
method of my root ViewController be executed in that case? That's where I instantiate the CBCentralManager
Some of the many online resources that I've found: