My app tracks location when connected to a specific Bluetooth device. I use expo-location for tracking and the react-native-ble-plx library for Bluetooth communications. However, I encountered a problem: if the app is closed by the user or the OS, the app still receives location updates, but when it tries to communicate with the Bluetooth module, it gets stuck and the promises never resolve.
This issue does not occur when the app is started with the UI or as a background service. It only happens when the app is started by a location change trigger.
Is this behavior due to Android OS restrictions on Bluetooth usage in such a context? Are there any known workarounds or solutions to ensure Bluetooth communication works even if the app is started by a location change trigger?
Here is an example of the problematic code:
const manager = BleManager();
await manager.state(); // This promise, for instance, never resolves
Nick P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.