Open ArthurRuxton-DY opened 2 months ago
Hi @ArthurRuxton-DY
Where do you store your bleManager
? According to the documentation it should be initialized once, outside of React.
Aside from that, your code looks fine, so I would need more context to determine what's causing the error.
Hi @intent-kacper-cyranowski thanks for your response. I have a custom hook where all blw methods live. Originally my bleManager was initialised at the top of that file, so outside of React. I think Android 13 did not agree with some other aspect of my set up.
In the end the only way to get my implementation to work on all api levels was to initialise the bleManager after permissions had been granted rather than before. This solution actually caused the same bug in IOS, so now I conditionally initialise the bleManger before / after permissions are granted.
for IOS: initialise bleManager > request permissions > check permissions granted > start scanning for Android: request permissions > check permissions granted > initialise bleManager > start scanning
Prerequisites
Expected Behavior
startDeviceScan should work as normal
Current Behavior
My app works on ios, android 11, android 14. It also works on android 14 when running with metro (npx react-native run-android) When running the published app, startDeviceScan always errors with "BleManger was destroyed". I've even tried conditionally reinitialising bleManager imediately before device scan: if(!bleManager) bleManager = new BleManager()
Library version
3.2.1
Device
all android 13 (api level 33) devices
Environment info
Steps to reproduce
attempt startDeviceScan in published app on android 13 (api 33)
Formatted code sample or link to a repository
Relevant log output
Additional information
No response