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)
Related
My Problem: I have an app that communicates with a medical BLE device. I have it all working but my problem is that when an ios user puts the app in the background I stop getting/processing the messages sent via bluetooth. Android seems to keep getting these messages but from what I've found, on iOS, the JS bridge is torn down and there isn't a solution out there for this problem. The phone must continue to process the data sent from the BLE device.
My thought is this and this is my question for you all.
Would it be possible to create a native module for ios that will always be running and be doing the following: getting ble data as it is notified. Store that data to the file system and push it to a webservice all while the app is in the background? It would also be great to have the ability to read the fs created files and show some data about them when the app comes back to the foreground. Would this be possible?
Do you know of another option that could work?
Any help is greatly appreciated.
OK as I was heading down the native path and reading on the ios bluetooth schtuff I found this article Core Bluetooth Programming Guide and specifically it mentions a plist setting.
The Core Bluetooth background execution modes are declared by adding the UIBackgroundModes key to your Info.plist file and setting the key’s value to an array containing one of the following strings:
bluetooth-central —The app communicates with Bluetooth low energy peripherals using the Core Bluetooth framework.
bluetooth-peripheral —The app shares data using the Core Bluetooth framework.
So I thought to myself, would just by adding these keys to my xcode project that iOS would be smart enough and not care that I am a RN app and not native... well that was the ticket! I plugged these values in and the ble data is processed even when I open another app. "Wallah!" ;)
You have to enable iOS background mode capability in your Xcode project settings.
Also take a look at react-native-ble-plx which provides background support for both iOS and Android.
I'm using MobileFirst Platform 7.1 with Paho MQTT (Internet of Things), I'm trying to implement a Hybrid Application with mqtt for Android and iOS.
I have tested the app in Android and it is working as expected, when it is in the foreground and background,
While in iOS, it does not work as expected. It works correctly in the foreground, but not in the background. I was testing using the iPhone Simulator of XCode and iPhone 6.
I found a project which implemented with MobileFirst and MQTT. from https://developer.ibm.com/mobilefirstplatform/documentation/integration/mq-telemetry-transport/
i am just adding host and port number and adding android,ios environment.but same problem facing android working iOS not.
at this moment what can i do ?
UPDATE:
in iOS, it works correctly foreground.but when i send background the "MQTT client" connection lost form broker.
this method fire :
this.client.onConnectionLost = function() {
alert("Connection lost!");
};
on the other hand , android , windows it work perfectly for foreground and background
For example :
I have a room there have a PIR sensor. it work like publisher . my application user is a subscriber .
when user out the room that that time she open application,subscribe and
send application background.
anytime someone entire the room that time , she will be get a notification.
Details on how to run in the background on iOS can be found here. This link also lists the actions that Apple allows to run in the background, if your app does not meet those criteria then it is likely to get bumped from the app store.
The list also shows which UIBackgroundModes to place in your Info.plist to flag that your app needs background access.
I can not found at least one way to mange it for hybrid application ,tried with several way ,failed and mange it easily for native application MQTT iOS background.
Todos
Plan support for new platforms (iOS, Windows Phone)
Add background service support in Android version
more check this link https://github.com/arcoirislabs/cordova-plugin-mqtt
I am working with the Microsoft Band SDK on iOS and I have a question on restoring connectivity in the background when using the Band SDK. With the Band SDK you connect via Microsoft's API rather than directly to the bluetooth device using Bluetooth Core on iOS. This gets you several events including device connected, device disconnected, etc.
The problem I am having is how to restore a connection if the device disconnects, such as going out of range. I would like to be able to restore the connection when my app is in the background without having to bring the app back to the foreground. I have added the bluetooth background modes to my Info.plist, which allows me to process events from the device in the background but any attempt I make from the background to restore the connection never seems to complete until I bring the app to the foreground.
All the documentation on state preservation with Core Bluetooth seems to only apply if I am managing the device myself using the CBCentralManager, however since I am using Microsoft's Band SDK as an intermediary I don't believe I can use this.
So any help on how I can restore the connection via the Band SDK API while my app is in the background would be appreciated. I know the correct API calls to make I'm just unsure how/if they can succeed while my app is in the background.
Direct access to the Band via Core Bluetooth is not supported for 3rd party apps. So, managing the Band from CBCentralManager will not be possible from your app.
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.
I have created an iOS app that interacts with a bootloader on some custom hardware/firmware to update the application on the hardware. In order to accomplish this, the hardware/firmware has a bootloader application and a regular application. First, I connect my iOS app to the bootloader application and update the regular application. At which point the regular application starts to run and I would like to connect to it with my iOS app.
If I search for peripherals with an Android application it correctly sees my hardware broadcasting as the bootloader application and then switch to broadcasting as the regular application after the update has been completed. However, for some reason, the equivalent iOS app only sees it being broadcast as the bootloader application. I have found that if I restart the iOS device or if I turn the iOS device's bluetooth off and back on after a few seconds it will finally recognize that the regular application is broadcasting.
It seems as though the iOS device is caching the peripheral information. Does anyone know if there is a way to clear the cache or refresh to get the current/valid status of the device?
I have exactly the same issue here, unfortunately this is indeed due to iOS. There are a lot of other threads about this topic but after looking for a while I would recommend this answer :
https://stackoverflow.com/a/25930825
Best of luck, I haven't finished yet and this won't be easy...