Comments (19)
I would really appreciate this feature as well, if there's something I can do I'd gladly offer my help π
from react-native-ble-plx.
Hi,
Have you turned on bluetooth background mode on iOS?
You could only do it entering proper info in plist.
In this way, when bluetooth action is happening(for example notification on characteristic), your iOS app is woken up by the system and have a bit of time to do it's job.
from react-native-ble-plx.
I certainly need to test it on both Android, iOS and check if any API changes or additional steps are required.
from react-native-ble-plx.
@Kacper20 Turning on bluetooth-central
background mode doesn't seem to make any difference. Something more has to be done.. :)
The app continues from where it was left. Tested also with Instruments' Time Profiler and there seems to be no activity.
from react-native-ble-plx.
I'm working on this for Android. I think the app needs a scheduled background job to do this.
from react-native-ble-plx.
Hi guys!
I just found out that the background monitoring actually works out of the box (with background-mode turned on).
I had beed sending requests to my device to response me with data and that didn't work.
Instead of that, now I send the data from my device (Arduino with BLE chip) automatically without the need of the request and the app will continue to monitor and receive that data after turning display off. π
This was tested on iPhone.
from react-native-ble-plx.
@stami Have you tried killing the app?
from react-native-ble-plx.
@vikeri Sorry for delay.. I hadn't notifications on for this thread.
Killing the app? In order to achieve what?
Currently the connection breaks if I reload the app. Haven't tried bundling and building release for some time...
from react-native-ble-plx.
@stami My experience is that it works as long as iOS/Android keeps the app in the memory. As soon as they kill the app due to inactivity or otherwise high memory load the BLE connection will be lost.
from react-native-ble-plx.
@vikeri I haven't got much knowledge on this but to me, that sounds something that cannot be helped even with native code.
from react-native-ble-plx.
@stami True, what I did was to put the code in a background job that schedules every 15 min. Then the app is woken up in the background and reconnects again to the Bluetooth. I did a library for it (only Android atm) vikeri/react-native-background-job
from react-native-ble-plx.
@Kacper20 Is there any known blocker for supporting state-restoration for iOS? Otherwise i would start working on that.
from react-native-ble-plx.
@mane87 It's supported on backing RxBluetoothKit
library, so I think that it's just the matter of creating API and wrapping this calls in JS.
@Cierpliwy any objections?
from react-native-ble-plx.
I don't have any objections really. All I want is an API which won't require iOS/Android specific JS code. I'm not sure if it's doable though.
from react-native-ble-plx.
To be precise:
I'm talking about State Restoration
section from Bluetooth Programming Guide.
There's detailed description provided by Apple here
RxBluetoothKit
has listenOnRestoredState
method, which you should subscribe to after re-instantiating BluetoothManager
(on applicationDidFinishLaunching
).
We need to have API from side of this library to wrap this one call, but I'm sharing @Cierpliwy doubts that this would have to be platform-specific logic, since this differs so much on Android and iOS.
So we would have to implement method that would have to be only available on iOS. Since I'm not really into ReactNative I don't know whether it's possible to do this in a nice way and how it'll affect library.
Does this answers your question @mane87?
from react-native-ble-plx.
@Kacper20 @Cierpliwy Thanks for the fast answers guys. Sounds good. I'll have a look at it and see if i come up with a clean solution.
from react-native-ble-plx.
Hey guys, it's a really great feature, any news?
from react-native-ble-plx.
@edencakir Background monitoring is working.
As for state restoration, that is totally different question and should be discussed in another thread, in my opinion.
I opened this issue and consider it solved. Background monitoring was working, I wasn't just using it correctly as I was trying to poll the data instead of just monitoring changes.
I'm closing this issue now. Please create another one for state restoration. :)
from react-native-ble-plx.
Glad to hear that.
Currently, without any additional setup, the app just does nothing when phone screen turned off. Monitoring (or receiving the values) continues after the app is opened again. (tested only on iOS)
Your comment made me confused, thank you for the clarification.
from react-native-ble-plx.
Related Issues (20)
- π iOS example app does not want to start HOT 1
- π empty known devices list on Android HOT 4
- IOS Service UUID does not getting HOT 7
- Support sharing JSON data between devices HOT 2
- π The onstatechange was not fired if the app's blue permission was disabled HOT 5
- π IOS\Android disconnecting from bluetooth device after connecting if we don't write characteristics after 30 seconds. HOT 4
- π BluetoothLE is in unknown state, but the state is PoweredOn HOT 7
- Auto-disconnection in some Android devices HOT 5
- π Scanning devices, it only finds my ble beacon on Android 11 (it doesn't on iOS 17.5.1 and Android 14) HOT 2
- I have connected to the IoT device, but I still cannot get the data sent by the IoT device. Does it not support the Bluetooth serial port? HOT 1
- Read characteristic in background? HOT 2
- isDeviceConnected return BleErrorCode.DeviceDisconnected instead of falseπ HOT 2
- πManufacturerData on iOS returning null, in Android is correctly setted HOT 20
- Issue with [BleError: Operation was cancelled] on iOS 17 HOT 10
- π Module does not work with Android Auto, when there is no Activity
- Is it possible to define Characteristics and Serivces that should be available on a mobile device acting as a peripheral? HOT 1
- How can i use this package to emitter beacons HOT 1
- Forking and building locally
- Discovering nearby users HOT 2
- π startDeviceScan errors with "BleManager was destroyed" on android API level 33 (android 13) when published (works fine when running with metro) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-ble-plx.