Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 602
user1122025 Avatar asked Jan 10 '12 02:01

user1122025


2 Answers

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.

like image 101
Dennis Mathews Avatar answered Oct 31 '22 22:10

Dennis Mathews


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"

like image 20
Matt Connolly Avatar answered Oct 31 '22 21:10

Matt Connolly