Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can we access the heart rate directly from the apple watch? I know this is a duplicate question, but no one has asked this in like 5 months. I know you can access it from the Health App but I'm not sure how "real-time" that will be.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
552 views
Welcome To Ask or Share your Answers For Others

1 Answer

Heart Rate Raw Data information is now available in Watchkit for watchOS 2.0.

WatchOS 2 includes many enhancements to other existing frameworks such as HealthKit, enabling access to the health sensors that access heart rate and health information in real-time.

You could check this information in the following session which is total 30 minutes presentation.If you do not want to watch entire session, then you directly jump to Healthkit API features which is in between 25-28 min:

WatchKit for watchOS 2.0 Session in WWDC 2015

Here is the source code implementation link

As stated in the HKWorkout Class Reference:

The HKWorkout class is a concrete subclass of the HKSample class. HealthKit uses workouts to track a wide range of activities. The workout object not only stores summary information about the activity (for example, duration, total distance, and total energy burned), it also acts as a container for other samples. You can associate any number of samples with a workout. In this way, you can add detailed information relevant to the workout.

In that given link, the following part of the code defines sample rate of heartRate

NSMutableArray *samples = [NSMutableArray array];

HKQuantity *heartRateForInterval =
[HKQuantity quantityWithUnit:[HKUnit unitFromString:@"count/min"]
                 doubleValue:95.0];

HKQuantitySample *heartRateForIntervalSample =
[HKQuantitySample quantitySampleWithType:heartRateType
                                quantity:heartRateForInterval
                               startDate:intervals[0]
                                 endDate:intervals[1]];

[samples addObject:heartRateForIntervalSample];

As they state there:

You need to fine tune the exact length of your associated samples based on the type of workout and the needs of your app. Using 5 minute intervals minimizes the amount of memory needed to store the workout , while still providing a general sense of the change in intensity over the course of a long workout. Using 5 second intervals provides a much-more detailed view of the workout, but requires considerably more memory and processing.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...