1
votes

I am trying to use a BluetoothLowEnergy plugin for Cordova to scan for nearby iBeacons. I have tried both the cordova-plugin-eddystone

evothings.eddystone.startScan(successCallback, errorCallback)

and the BluetoothLE

bluetoothle.startScan(_successCallback, errorCallback, {allowDuplicates: true});

However I can't make the scan to work on background. I enabled background capabilities in the .plist with Xcode, specifying that the app utilizes BLE sensors. Moreover, I use the de.appplant.cordova.plugin.background-mode plugin, executing after the deviceReady event the function:

cordova.plugins.backgroundMode.enable();

However the scan just pauses when entering in background mode. No matter what. Is there any alternative way? Is the background mode disabled in the eddystone plugin? Thank you

1

1 Answers

0
votes

From what I'm seeing, the de.appplant.cordova.plugin.background-mode plugin uses the Audio background mode to keep the app running in the background, so you need to enable that one instead.

Keep in mind, as noted in the README file of this plugin, this is not App Store compliant, and your app won't pass the review process. Basically, you can only use the Audio background mode if you're building an audio app, and even then you should (must?) only use it for playing audio in the background, not for scanning beacons.

Also, you haven't mentioned which exactly Eddystone plugin you're using. Have you verified it's actually capable of running in the background? Being able to detect Bluetooth devices in the background requires some special considerations, so it might be simply that the plugin doesn't support it. If you confirmed it does support it, it might be a good idea to inquire further with the authors of the plugin themselves.