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?
Open the Heart Rate app on your Apple Watch. Tap Current, Resting Heart Rate, or Walking Average to show your heart rate throughout the day.
In addition, Apple Watch measures your heart rate throughout the day when you're still, and periodically when you're walking (Apple Watch Series 1 or later).
The WATCH LINK™ pod enables you to stream heart rate from your Apple Watch to any ANT+ compatible equipment. You must have either a WATCH LINK™ pod in order to use this app. The app requires connection to a pod prior to starting a workout.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With