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".

user1122025
  • 426
  • 5
  • 15

2 Answers2

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.

Dennis Mathews
  • 6,897
  • 2
  • 26
  • 39
  • 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. – user1122025 Jan 10 '12 at 03:13
  • Do you have UIBackgroundModes set to external-accessory in your info.plist ? – Dennis Mathews Jan 10 '12 at 03:48
  • 3
    @DennisMathews I think you want the `bluetooth-central` if you're using CoreBluetooth... – Jason Coco Jan 10 '12 at 04:09
  • 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. – Zaraki Apr 24 '12 at 10:58
  • Can Anyone help me to keep app live in background?, I tried above solution but no success. Please help me out... – Chetan Bhalara Nov 30 '13 at 10:45
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"

Matt Connolly
  • 9,757
  • 2
  • 65
  • 61