Giter Site home page Giter Site logo

Comments (19)

vikeri avatar vikeri commented on September 9, 2024

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.

Kacper20 avatar Kacper20 commented on September 9, 2024

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.

Cierpliwy avatar Cierpliwy commented on September 9, 2024

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.

stami avatar stami commented on September 9, 2024

@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.

vikeri avatar vikeri commented on September 9, 2024

I'm working on this for Android. I think the app needs a scheduled background job to do this.

from react-native-ble-plx.

stami avatar stami commented on September 9, 2024

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.

vikeri avatar vikeri commented on September 9, 2024

@stami Have you tried killing the app?

from react-native-ble-plx.

stami avatar stami commented on September 9, 2024

@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.

vikeri avatar vikeri commented on September 9, 2024

@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.

stami avatar stami commented on September 9, 2024

@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.

vikeri avatar vikeri commented on September 9, 2024

@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.

mane87 avatar mane87 commented on September 9, 2024

@Kacper20 Is there any known blocker for supporting state-restoration for iOS? Otherwise i would start working on that.

from react-native-ble-plx.

Kacper20 avatar Kacper20 commented on September 9, 2024

@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.

Cierpliwy avatar Cierpliwy commented on September 9, 2024

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.

Kacper20 avatar Kacper20 commented on September 9, 2024

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.

mane87 avatar mane87 commented on September 9, 2024

@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.

edencakir avatar edencakir commented on September 9, 2024

Hey guys, it's a really great feature, any news?

from react-native-ble-plx.

stami avatar stami commented on September 9, 2024

@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.

edencakir avatar edencakir commented on September 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.