I've developed an iOS app using React Native that needs to establish a Bluetooth Low Energy (BLE) connection with a device and continuously retrieve ECG data from it. My goal is to ensure that this connection and data retrieval continue to function even when the app is in the background or minimized. However, I've noticed that after a few minutes, the app stops receiving data, and it seems that some variables are re-initialized.
Here's a simplified overview of my setup:
The app establishes a BLE connection with the device and retrieves ECG data.
I'd like this connection and data retrieval to persist even when the app is in the background.
After a period of time, the app appears to stop receiving data, and certain variables seem to be re-initialized. My questions are:
Background Execution: What strategies can I use to ensure that my app remains active in the background? Is there a way to extend the period during which the app can operate in the background without being suspended?
Variable Persistence: How can I prevent variables from being re-initialized when the app is in the background? I'd like to maintain the state of certain variables even when the app is minimized.