Objective-C/iOS: Keeping bluetooth connection alive in the background
Asked Answered
C

2

9

I've been researching this for a couple of days now and looks like it's not possible to keep bluetooth connection alive while the phone goes to sleep or if the app is in the background. However, I have found one app that claims they can run all the time: RunKeeper app says:

What's New In Version 2.5.1.0

  • Support for tracking heartrate in the background with Wahoo heartrate monitor.

Does anyone know how they manage to send heart rate data to the phone while the app is in the background?

UPDATE:

Got it working by adding an entry in my plist under "Required background modes" for "bluetooth-central".

Clasping answered 10/1, 2012 at 2:57 Comment(1)
were you able to keep it alive in the background for more than 10 minutes?Leroy
M
7

You need to use the new Bluetooth Low Energy feature via the CoreBluetooth Framework Also note this is available currently only on iPhone4S since the Bluetooth Low Energy capability is dependent on the Bluetooth hardware in the iPhone.

Mabellemable answered 10/1, 2012 at 3:0 Comment(5)
Thanks, I am using the CoreBluetooth Framework. Our app and BLE connection works fine while the app is running. The problem is when the phone goes to sleep or if the back goes to the background, the BLE connection stops working. I haven't seen anything in the CoreBluetooth Framework about keeping the connection alive in the background. When the app is in the background and we press a button on the BLE device, the phone gives a notification saying that the device needs access to the app so I have to open the app manually again.Clasping
Do you have UIBackgroundModes set to external-accessory in your info.plist ?Mabellemable
@DennisMathews I think you want the bluetooth-central if you're using CoreBluetooth...Versicolor
so bluetooth-central is for iOS 5.0 and above.. is there any way of doing the same in 4.x ?? If yes please help.Whittemore
Can Anyone help me to keep app live in background?, I tried above solution but no success. Please help me out...Aristaeus
D
2

In Xcode 5 there is a section for Background Modes in the your app's capabilities. Set Background Modes to ON and check "Uses Bluetooth LE accessories"

Diabolize answered 13/11, 2013 at 4:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.