New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to maintain bluetooth connection on page navigation/refresh/rerender? #622
Comments
If you need to monitor a characteristic across, it might make sense for you to handle the connection and monitoring in a service (for example) instead of doing it on the page. I'm not sure if that's your problem, but doing it on a service will guarantee that you don't drop any important variable or state when closing a page. |
Can you show how do you handle |
Thanks both, separating BLE from UI solved the issue for us! |
@jackbridger can you please elaborate on how you separated BLE from UI? was this done via a background service worker? https://github.com/devfd/react-native-workers |
@jackbridger , Hello, i have the same issue, can you please give an example of how did you separate BLE from UI please ? on android it works perfectly without the separation, on iOS everything works but only on the same interface. |
@MedRaid I found out how. You need to have the code that manages the BLE connection in a background worker. Here is an example using Saga https://github.com/Cierpliwy/SensorTag/blob/master/src/Saga.js In this example Saga is used to managed the BT connection in the background and writes to the Redux store what the current state of the connection is |
Thanks for maintaining awesome library
I have a questions about maintaining BLE connection when rerendering the page.
Currently we're doing all of our ble-plx stuff within a single page and testing with iOS
Right now we're just doing a count to isolate the issue. But every time we receive data from our arduino, we update the state of count.
The first time
setSensorData(`${count}`);
is called, our connection with the BLE device drops.
Is this because we're inside our page and it should take place at the app level or is there something else we need to do to maintain device connection when rerendering our pages/navigation etc.?
Thanks!
The text was updated successfully, but these errors were encountered: