UIBackgroundModes bluetooth-central

We have a requirement to have BLE connection in background to complete the initiated tranction for short period if user presses home button.

As we dont have any run time option to enable the BLE connection in background, we need to enable the Core Bluetooth background execution mode in info plist.

Our concern is if we enable it, would that affect power consumption, than avoiding it?

We would use background connection for a short period until the transaction is done.

Question here is, if we enable UIBackgroundModes and use the connection for short time, will that have still affect on power consumption?

Is there a better way to handle BLE connection for short time in background?

I can’t help you with the Bluetooth side of this; I don’t have a lot of experience in that space. However, I can answer the following:

Is there a better way to handle BLE connection for short time in background?

It sounds like the user has initiated some activity while your app was in the foreground and you need a little extra time to complete that activity after the user has moved you to the background. Is that right? If so, that’s exactly what the UIApplication background task API was designed to help with. I’ve posted about this API extensively in the past, but today I decided to call all of my notes into one place, namely a new UIApplication Background Task Notes post.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Thanks Quinn for the details.

You are right that we need to complete the activity in background but it also needs BLE connection to be active for that activity.

When I had tried this, thought I could run the activity, it failed to complete becuase BLE connection got disconnected.

I assume its triggered by iOS once an App goes to background and we dont have control over it until we use backgroundMode.

It would be great if you could suggest better way to handle this situation.

Accepted Answer

I assume its triggered by iOS once an App goes to background and we dont have control over it until we use backgroundMode.

The short answer here is, alas, “I don’t know for sure.” I’m drawing on my experience from the networking world, where the network subsystem works fine in the background as long as you don’t get suspended. I kinda suspect that the same thing would apply to Bluetooth — otherwise you couldn’t do Bluetooth operations when you’ve been resumed in the background for some random reason, like background fetch — but I don’t know enough of the details to give you a definite answer on that front.

You might try asking over in Core OS > Bluetooth to see if folks over there have any input. Alternatively, you could **** it and see (-:

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
UIBackgroundModes bluetooth-central
 
 
Q