Wondering if the Evothings cordova BLE plugin is capable of running in the background and discovering devices while in background mode?
I updated my Cordova project to run in the background and I can confirm it's running via some console.logs in the code.
I also update the Objective C code in the BLE plugin to NSLog when it discovers a BLE device.
Interestingly enough, when the app goes into the background, the BLE NSLogs stop, while the logs from the Corodva app continue. The app continues to run, but no BLE devices are showing as discovered in the background.
I was wondering if this is just not possible, or if there is some config, etc. that I might need to do.
I already have the bluetooth-central entry in the plist for required background modes, but it doesn't seem to be helping.
BTW - I know this has some App Store implications, but right now I'm just trying to see if I can get it to work in any way.
Scan for BLE devices in the background?
Re: Scan for BLE devices in the background?
There are two tutorial articles on background in general, and beacons, hope you'll find some inspiration!
https://github.com/evothings/phonegap-estimotebeacons/wiki/Background-notification-guide
http://blog.estimote.com/post/105963606605/how-to-develop-beacon-apps-in-javascript-with
best
Alex
https://github.com/evothings/phonegap-estimotebeacons/wiki/Background-notification-guide
http://blog.estimote.com/post/105963606605/how-to-develop-beacon-apps-in-javascript-with
best
Alex
Re: Scan for BLE devices in the background?
Hi, it is definitely possible to scan in the background. What is needed is to add some definitions to the plugin.xml file.
For iOS, this is not currently added, but the plan is to do that. As I recall background mode already works on Android.
You can add the background modes required by iOS if you build your own Cordova app.
Edit the platform section for "ios" in plugin.xml in cordova-ble as follows:
It is the "UIBackgroundModes" that is added.
You would also need a notification plugin, such as this one: https://github.com/katzer/cordova-plugi ... ifications
Had some problems with this plugin to build on iOS, this is also on the todo-list to fix.
Best regards, Mikael
For iOS, this is not currently added, but the plan is to do that. As I recall background mode already works on Android.
You can add the background modes required by iOS if you build your own Cordova app.
Edit the platform section for "ios" in plugin.xml in cordova-ble as follows:
Code: Select all
<platform name="ios">
<config-file target="config.xml" parent="/*">
<feature name="BLE">
<param name="ios-package" value="EVOBLE"/>
</feature>
</config-file>
<config-file target="*-Info.plist" parent="UIBackgroundModes">
<array>
<string>bluetooth-central</string>
<string>bluetooth-peripheral</string>
</array>
</config-file>
<framework src="CoreBluetooth.framework" />
<header-file src="src/ios/EVOBLE.h" />
<source-file src="src/ios/EVOBLE.m" />
</platform>
It is the "UIBackgroundModes" that is added.
You would also need a notification plugin, such as this one: https://github.com/katzer/cordova-plugi ... ifications
Had some problems with this plugin to build on iOS, this is also on the todo-list to fix.
Best regards, Mikael
Re: Scan for BLE devices in the background?
Created an issue for adding iOS background modes to the BLE plugin: https://github.com/evothings/cordova-ble/issues/85
Re: Scan for BLE devices in the background?
Only bluetooth-central would be needed for the BLE central role (the plugin does not yet support peripheral role on iOS).
Return to “Questions and answers”
Who is online
Users browsing this forum: No registered users and 25 guests