I'm writing my own fitness app that I hope to bridge the void between the Fitbit app and Apple Health (I finally ditched my Blaze for an Apple Watch). So far I am able to retrieve the workouts for the last 7 days but I want to display a heart rate graph (like Fitbit does) for the workout when you click to view it. Does the workout contain the heart rate samples recorded during the workout or do I need to query the heart rate for start and end time matching the workout separately? I've played about a bit and tried to find the answer in the documentation but I'm finding it a bit difficult to understand so sorry if I've missed something obvious!
Heart rate is one of many factors that Apple Watch uses to measure your activity and exercise. Depending on your workout, it selects the most appropriate inputs for that activity. For example, when you're running indoors, it also uses the accelerometer.
A workout is a container for these types of information, taken as a collection of samples. A given workout might contain heart rate samples, distance samples and an activity type to categorize them. Continuing from the previous HealthKit tutorial, you're going to track a special kind of workout: Prancercise.
* Place the tip of your index finger on the iPhone's camera, and in a couple of seconds, your pulse will be shown! * Instant Heart Rate detects a color change in your finger tip each time your heart beats and uses an advanced algorithm to show you your heart rate.
The Workout app on Apple Watch does not associate heart rate samples with its HKWorkout
instances, so querying for heart rate samples using +[HKQuery predicateForObjectsFromWorkout:]
will not return any results. Instead, you should query for heart rate samples using a date range predicate spanning the duration of the workout.
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