react-native-ble-plx icon indicating copy to clipboard operation
react-native-ble-plx copied to clipboard

How can one restart the library/stack with a similar effect to killing and restarting the app?

Open hugows opened this issue 4 years ago • 1 comments

Hello friends,

first thanks for this wonderful library - its mostly a breeze for me and working with iOS and Android properly.

What happens to me now that more people are using my apps and sometimes we hit reliability issues - for example, in some devices in some situations, users just click all around frantically... and the app just stops scanning properly. (Of course this can also be just logic on the app side- but this happens regularly and in different apps..)

What I usually do in those times is to "kill" the app, which always works but I can't really ask users to do.

Is there any way to achieve a similar behaviour without closing the app ? I tried closing and opening the BLE manager but that didn't seem to trigger a low level restart.

Thanks in advance!

hugows avatar May 28 '21 09:05 hugows

Hey, we have a similar question/issue. In some cases when the BLE devices goes out of range or the power is turned off, and goes back online/in-range soon after, the library still finds the advertisement packages but cannot connect to the device anymore. The connection attempt always times out. After killing the app, as well as disabling and enabling Bluetooth on the phone, the problem is fixed, but this is giving us a headache in production Also note that restarting the BLE device does nothing, while the app 'nRF Connect' can always connect the device, so the problem is definitely somewhere inside the app logic / react-native-ble-plx library.

Our first solution was to restart the BleManager:

this._manager.destroy();
this._manager = undefined;
this._manager = new BleManager({restoreStateIdentifier: 'Some-identifier'});

This works on android, and works 50% of the time on iOS, but the other 50% of the time on iOS, BLE is completely broken. The status of the BLE then becomes 'Unsupported' and nothing works anymore.

ThomasStubbe avatar Jun 08 '21 12:06 ThomasStubbe

I'm excited to inform you that we've released a new version of react-native-ble-plx. Many of the concerns and bugs have been addressed in this update.

If you encounter any issues or have further suggestions, please don't hesitate to open a new issue.

abursztynowska avatar Oct 06 '23 08:10 abursztynowska