don / ble-background Goto Github PK
View Code? Open in Web Editor NEWUse cordova-plugin-ble-central to scan, connect, & receive notifications while app is in background
Use cordova-plugin-ble-central to scan, connect, & receive notifications while app is in background
Within this repo I have read all of the posts I could find about background syncing in iOS and reviewed the ble-background example, but that example only waits three seconds before starting the scan, so I am guessing the test app is only suspended, and not fully moved to a background state. Also, it's only running once instead of running repeatedly.
In my app I am using setInterval
to check every minute if there is a device that is due to be synced and in range by running ble.scan
. This process runs great while in the foreground, but when the app moves to the background the function specified in the setInterval command is no longer executed, which is why I think the ble-background example is not quite a full background syncing test.
I installed the plugin cordova-custom-config, added the settings for Background Scanning and Notifications on iOS, and verified those settings are being added to the Info.plist file. In the ble.scan command I am including a service that is specific to my device: ble.scan([config.bluetooth.custom.service], seconds, success, failure);.
I also installed the plugin cordova-plugin-background-fetch, which allows a javascript function to be executed every 15 minutes for 30 seconds. My function (which runs fine in the foreground) hangs when ble.scan is called and doesn't return anything. It seems that iOS is not allowing that command in this instance.
How are folks getting the scan to run at regular intervals in the background or otherwise connecting to peripheral devices in the background?
I start the scan, and press home button to put it in background.
Nothing happends until I bring it to front, and then the notification appears.
So clearly, no JS code is ran when the app is in background.
It makes the whole thing useless :(
For the build, I get the error code:
Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
I am running on MacOS Catalina v10.15.7. I can't add android platform nor build to ios platform.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.