don / cordova-plugin-ble-central

Bluetooth Low Energy (BLE) Central plugin for Apache Cordova (aka PhoneGap)
Apache License 2.0
942 stars 603 forks source link

Ionic app with regular Background BLE tasks #850

Open giowild opened 3 years ago

giowild commented 3 years ago

Hi all, does someone have already implemented an ionic+cordova only app(no extra Java code) able to perform regularly a background task with a BLE connection?

In particular I would like to perform a BLE connection, connect, fetch and disconnect, once every 15 minutes, in bakground, to a device with a known service UUID, with initial scanForServiceUUID after OS reboot or after Bluetooth adapter state change. I know there are background cordova plugins (https://github.com/katzer/cordova-plugin-background-mode) but these do not seem to perform background tasks REGULARLY and continously across phone restarts.

It would be great to know if anyone has already successfully done it and if additional Java code has been required.

Thanks a lot!

dariosalvi78 commented 3 years ago

can't be done with cordova currently. See https://github.com/apache/cordova/issues/120

giowild commented 3 years ago

can't be done with cordova currently. See apache/cordova#120

Just found this: https://github.com/transistorsoft/cordova-plugin-background-fetch

Did you already know that?

After background execution, I would need a way to update ngrx store and create local notification to the user if the BLE device is in alert state

dariosalvi78 commented 3 years ago

this looks like exactly what I was suggesting in that issue! What I am not sure is if the app has access to plugins though. Worth trying!

(and if you try it, let us know please)

giowild commented 3 years ago

Of course, I'm going to try that and also ask developer if plugin can fit this kind of use cases. He seems a very kind person... Stay tuned

MarcinDl commented 2 years ago

Hello,

did you write your app? If so, any explanations, tips and code would be great. ☺️

peitschie commented 2 months ago

There's an open question on Capacitor's background runner about whether plugin support is a possibility: https://github.com/ionic-team/capacitor-background-runner/issues/24