Connecting to a bluetooth device while app is terminated

Hello everyone!

I'm currently working on an iOS app developed with Swift that involves connecting to a specific ble (Bluetooth Low Energy) device and exchanging data even when the app is terminated or running in the background.

I'm trying to figure out a way to wake up my application when a specific Bluetooth device(uuid is known) is visible and then connect to it and exchange data.

Is this functionality achievable?

Thank you in advance for your help!

This will depend on what you mean by terminated. If the app has crashed, or has been terminated by the system (for example due to resource constraints), then yes, implementing Bluetooth State Restoration will relaunch your app.

If you want to be able to do this after the user has force quit your app, that is not going to be possible.

This tech note explains when your app can or cannot be relaunched for interacting with BLE accessories TN3115: Bluetooth State Restoration App Relaunch Rules https://developer.apple.com/documentation/dts-technotes/tn3115-bluetooth-state-restoration-app-relaunch-rules

You can read more about Bluetooth State Restoration here: Core Bluetooth Programming Guide, State Preservation and Restoration

<https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html#//apple_ref/doc/uid/TP40013257-CH7-SW5>

First of all, thank you for your response!

When i say terminated i meant swipe killed by the user. I would like to wake up my app to work in background (for a limited time, like 10 seconds) when a certain uuid or service cbuuid is near and detected by bluetooth. I think is something similar with notification system from applications, because even if i swipe kill Instagram it will continue to send me notifications. I think this should be somehow achievable.

You could also look into sending a silent background push to wake up the app when it is killed. When this data message is delivered, iOS will launch your app in the background and it can connect to a saved BLE peripheral to transmit data. While it is possible to work, the delivery is not 100% reliable and depends on a number of factors like low power modes, system budgets, rate limiting, etc.

More info here:

You could also look into sending a silent background push to wake up the app when it is killed.

If the user has signal that they don’t want your app running in the background by swiping up in the multitasking UI, your app will not receive silent push notifications.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Hello,

we are developing a Bluetooth Low Energy device which can be paired with our app and trigger an http call in critical situations.

Our device triggers these routines as long as the app is active but after terminating the app the BLE device no longer is able access the background BLE process.

Is there a way to trigger an http call via BLE in emergency situations?

Greetings and thanks in advance!

Like mentioned in the various posts above, if the user terminates the app by swiping it away, it is not possible for that app to continue with the existing CoreBluetooth activities and get relaunched by CoreBluetooth until the user launches it from the Home Screen themselves.

As mentioned above, an iBeacon advertising will indeed relaunch a terminated app, but that will require changing your device. It requires careful implementation so either functionality does not get off the specifications.


Argun Tekant /  DTS Engineer / Core Technologies

Connecting to a bluetooth device while app is terminated
 
 
Q