BLE CoreBluetooth in Background, what I am authorized to do? - ios

I've designed a very simple wearable BLE device with one physical button. This device has a UART Service and can notify a connected device when the value change (when the button is pressed).
My goal: The smartphone must be able to send an HTTP request in background every time the button is pressed. even when the app is not running.
For this need, I have to implement the iOS Bluetooth background process with CoreBluetooth. But before, i would like to know if CoreBluetooth can meet my need.
So my questions are:
Is it technically possible to keep a long-term background connection between Smartphone and BLE device, even if the Smartphone reboot.
Can I wake up or start my app in foreground (without notification) when the BLE device button is pressed.
And if the previous statement is not possible, can I execute a very basic HTTP request in background when the user press the button ?
Thank you for your help!

Related

swift: How to make a call when phone is locked or app in background

I have implemented Agora call in iOS app which works perfectly fine when app is in foreground ... Actually in my case we initiate call through Bluetooth BLE iBeacon. Along with this we call an API which is also working fine.
Problem is when app in background or when phone is locked ... Even when app is in background, app listens bluetooth event and Call API but it never start Agora call until we bring app to foreground. Means call works in foreground or it waits to start call when app enter in foreground.
To handle this I implemented local notification to prompt user to tap notification and bring app to foreground. But we want to do it through Bluetooth iBeacon. That instead of user to tap notification, it press beacon button to bring app in foreground and start call. On beacon button press I can catch the event in background as well but unable to bring the app to foreground.
Could not find some solution of it. But seems like its do-able as with Car tablets which are connected with bluetooth to phone we can dial a number on tablet and through bluetooth communication with phone it makes a call to selected or dial number even when phone is locked.
Means third party bluetooth devices can send command to locked phone and initiate call.
There are two ways using that you can make calls when app is in background or in locked state even your app is in killed state.
Using CallKit Framework provided by apple.
You can send custom push notification to the user and on click of push notification application is wake up and call is happen.

iOS - What does External accessory communication of Background Modes do?

I guess it is a background mode related to ExternalAccessory.framework.
But the document about External Accessory says, "If your app is suspended in the background when an accessory notification arrives, that notification is put in a queue. When your app begins running again (either in the foreground or background), notifications in the queue are delivered to your app. Notifications are also coalesced and filtered wherever possible to eliminate any irrelevant events. For example, if an accessory was connected and subsequently disconnected while your app was suspended, your app would ultimately not receive any indication that such events took place.".
This means that the external accessory communication will be just queued until the app enters foreground mode, But the other background modes like Location, Bluetooth LE are working as real-time in background mode. So I doubt that just queued is the only thing that can do. Is it really?
If your external device is "Made for iPhone/iPod/iPad" - MFi you can use this option. It's not for BLE communication.

How can you use a button to send a vibrational pattern to another iOS device in swift?

The user enters another user's phone number. If both people are inside the app simultaneously, each user can tap a big button which makes the other person's device vibrate simultaneously. How can I make the button make the other person's iOS device vibrate?
You need to establish some line of communication between the two devices. This is a very vague question, in general, but to get immediate vibration, you'll want some server communicating over a socket with both devices. If one device presses the button, it tells the server to vibrate the other device. The server then tells the other device to vibrate.

How to send battery updates to LE accessory from app in background when iPhone operate in peripheral mode?

I'm developing a BLE enabled App. In my App iPhone operate in peripheral mode with Bluetooth accessories. Everything works fine until I go to background Mode Because my Phone is working as peripheral so It also update accessory with battery level it doesn't work in background because app will only wakeup once accessory will send request because its already subscribe for the update I somehow have to wakeup my app in background mode and send update let's say every x minutes .
I have already enable Bluetooth LE accessory background mode.
Apparently enabling background mode only gives the 'right' to run in the background whenever there is an event triggered.
One of the method is what you already did by 'polling' from the accessories periodically by sending request to wake up the app and execute the task.
Another way is to use background refresh. The only downside of background refresh is the event will not occur at specific period. It was mentioned at about 10-15mins typically or it might tag along with other app background wake up. If the update is not very frequent or crucial, this method would probably better for your case.
You can keep your app running in background by setting the "required background modes" option in your plist. Select "App communicate with accessory".
Please see the attached image for reference

Advertising with iBeacon when app is in background

I have been digging all forums and tutorials about transmitting in background mode with iBeacon. Until now, I couldn't find something solid which can help me. My app can successfully receive and transmit but when I press home button, transmitting stops and connection on other device/devices disappear. In myApp.plist, I added required keys but still nothing works. The question is, how can I make my app keep transmitting in background mode?
iBeacon will not advertise (transmit) in the background. If you need this you will not be able to use iBeacon and will instead need to implement your own BTLE advertisement (which will run in the background).

Resources