PhoneGap BLE plugin doesn't work in background - ios

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

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.

Related

Can I make a purely voice driven app in Expo?

I want to create an Expo app for ios that will say something, and wait for my reply, via headphones. The headphones part is immaterial but it indicates what I want... which is for this to run while my phone is locked and in my pocket. Once I have replied, the app would proceed. I have built Expo apps but I am unsure of whether an app can still interact with me via audio and the microphone in this way while the phone is locked. Also, I don't know if Expo has introduced this sort of capability. I also don't know if React Native (i.e. ejected Expo apps) can do this sort of thing. The lack of apps that truly interact in this way (not via Siri etc) are far and few between so I'm assuming it's a hard problem to solve. I would be just as happy if I could have a browser page running on the device do the same thing, but I'm pretty sure webpages can't play audio and wait for replies when a phone is locked. Is any of this possible at this point?
I did research this online, just to be clear. I wasn't able to find an answer so I came here. I mention this because this whole post does have that 'can you research this for me' vibe. I'm just hoping someone has knowledge of what is possible.
There is a page in the expo documentation that says when not to use expo, and the following is in there:
The SDK doesn't support all types of background code execution
Background execution is the ability to run code when the app is not foregrounded or the device is sleeping. We support background geolocation (including geofencing) and background fetch, but we do not yet support background audio with the operating-system playback controls and you cannot handle push notifications in the background. This is a work in progress.
You can take a look at it here.
I think you can do it in React Native though, however I can't say if there is a library to do it, so you can try creating your own with native code. You can see how here for android and here for ios.

is it possible to run Scan Beacon when app is Killed

Hello I'm new developer so i need some help Now. I was Bullied app doing Brodcast and Scan Beacon i used flutter_beacon 0.3.0
and for Brodcast i use beacon_broadcast 0.2.1 its working good for Advertising and Scan event when app is Background,but when app is kill or i remove app from list Running applications the Scan and Brodcast not Working
Now My Question is How to running code scan and Brodcast when app is killed or Finished ???
Yes, it is absolutely possible to resume beacon scanning on both Android and iOS after an app is killed. But the specifics of how you do this are different between iOS and Android. Further, the use of non-native development frameworks like FlutterBeacon make things more complicated as the documentation is not as complete for this use case.
While I am not an expert on FlutterBeacon, I am the lead developer on the underlying Android Beacon Library which it uses under the hood. I am also very familiar with how iOS CoreLocation works (which it also uses under the hood.)
In general here are the rules to get apps to detect after being killed:
iOS:
Start beacon monitoring (not just ranging) in the didFinishLaunching method of the AppDelegate
Obtain ALWAYS Location permission
After the app is killed it will be re-launched in the background when all beacons disappear or the first beacon appears in a monitored region.
Android:
Start beacon monitoring in the onCreate method of an Android application class using RegionBootstrap. See here for a discussion on the FlutterBeacon github
Obtain BACKGROUND_LOCATION permission from the user.
On Android 8+, your app should restart within 25 minutes of being killed and give you a callback to the BootstrapNotifier methods as appropriate.

TokBox iOS - App Background process singal not working

We are facing some strange issue in the iOS app , we are handling the signal when app in background mode.
It's perfectly working in xcode simulator and the same thing it's not working in real iOS devices. The signals not receiving in app background mode.
Do we need to enable any settings in iOS devices to handle this?
And, It's perfectly working in android devices.
Please help on this.
(Also Project->Capabilities-> Background Modes -> Audio,AirPlay,PIP is enabled for this to work in background.)
Apps sent to the background are generally expected to get suspended unless there is a reason for the process to stay running. In the case of using the OpenTok SDK, usually this means the app will be suspended unless there is a Publisher and/or Subscriber running -- background permission is tied to the AVAudioSession.
If you are trying to just keep a session connected without any subscribers/publishers while the app is in the background, this is not a recommended implementation. Keeping a websocket active for an OpenTok session requires trickling data every few seconds, creating an unnecessary burden on energy and data costs. For this reason, it is recommended to do your offline signaling via APNS rather than through an OpenTok session.
I trust you may have already seen this, but just for completeness, a more in-depth writeup on the topic is available here: https://tokbox.com/developer/sdks/ios/background-state.html
Disclosure: I work for TokBox.

cordova plugins bluetooth background service

I'm currently trying to make an IOS app with cordova. While reading the doc for bluetooth I was wondering if it was possible to have the cordova plugins to handle the "Reinstantiate Your Central and Peripheral Managers" part.
Since that part should not required to bring the app foreground to interact with the bluetooth device, will the plugin will be able to wake up ? or will the cordova part must be wake up to ?
Is there a way to simplify the implementation ?
I'm kind of new with the bluetooth technology and I don't have much knowledge with cordova plugin. I'm still currently trying to make it work but I would like to know if it is possible.
For now I'm doing the app like so:
cordova will handle the interface to setup the data and settings and the plugins will handle all the interactions with the bluetooth device. I'm trying to make the plugins, the part that will be restored when a know bluetooth device is connected (in the hope it do so even when the phone is locked) and make it handle the data transfert without the app being put in the foreground or even lunched in the background (I would like to have only the plugins part to be wake up)

iOS Core Bluetooth app used like a Central doesn't work in background

I've an app that uses Core Bluetooth in foreground, everything is working fine. Now I'm trying to enable the background usage, I checked the correct options in Capabilities like the documentation says but the sync doesn't happen, only when I call the app to foreground again. Someone had this problem also? Should I implement more things like "State Preservation and Restoration"?
Just to be more clear, I'm using a specific UUID.

Resources