Live Heart Rate in watchOS 3
Asked Answered
M

1

7

I'd like to access the live heart rate at in my apple watchOS app. In the keynote they emphasized that developers can access the live data now. But I can't find anything about it in the documentation.

Does anyone have a hint for me?

Malcom answered 2/7, 2016 at 9:57 Comment(4)
Can you provide the code you've started with or where you're stuck specifically?Mosa
the thing is I dont know, how to get started. I try to understand of live heart rate in watchOS 3. But: I've found this github project, looking in to it right now github.com/coolioxlr/watchOS-3-heartrateMalcom
Being able to access heart rate is not new in watchOS 3. What did change is that workout apps are now able to stay running while the Apple Watch screen is off, meaning that heart rate samples can be processed live during a workout session, even when the user is not directly interacting with the app.Chide
Have you created other watchOS apps? I think you should give it an honest effort before asking for help.Mosa
I
11

The GitHub project you mention (github.com/coolioxlr/watchOS-3-heartrate) in your comment is a really good place to start.

In order to get the heart rate data, your app is going to first need to request read access to HealthKit for the heart rate data. Unfortunately, you are unable to get the data directly from the sensor so you will have to query for it from HealthKit. To do so, you will need to create a streaming query. If you want it "live" or with a high sampling rate, you should create a workout session. Just remember to end the workout session (particularly while testing) because otherwise the workout continues (you will see the little green workout icon at the top of your watch face) and your watch will burn through the battery. If that happens open up the Apple work out app on your watch, start a work out, and then end it, as starting a new workout session ends an old one.

I hope this helps you get started :)

Isa answered 26/9, 2016 at 21:3 Comment(1)
thank you for the advice! I actually started with it and got most of the basic stuff figured out. Now I am having trouble with playing audio feedback. But that is a different story.Malcom

© 2022 - 2024 — McMap. All rights reserved.