Here's how the app works - it connects to the device over Bluetooth (library is react-native-ble-manager), and sends a “request” with writeWithoutResponse
for the info register (this contains information like device battery %, error status, etc) every 5 seconds. The app then “listens” for any response from the device using bleManagerEmitter.addListener("BleManagerDidUpdateValueForCharacteristic")
. When it gets a response that’s the info register response, it updates the app’s state.
The problem is that we need to implement background error checking. In theory the app would keep sending the info register request every 5s when the app is in the background, which the app would then check, and if there’s an error trigger a push notification.
I can connect to the device over Bluetooth and send writeWithoutResponse
requests when the app is in the background using react-native-background-actions, but the problem is that I get no response back from the listener - I'm assuming the BT listener just can’t be active in the background? I’ve had a look at the library docs / issues and can't find this existing problem.