Objective-C/iOS: Keeping bluetooth connection aliv

2019-03-13 13:57发布

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

2条回答
干净又极端
2楼-- · 2019-03-13 14:27

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.

查看更多
贼婆χ
3楼-- · 2019-03-13 14:28

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"

查看更多
登录 后发表回答