I’m developing a watchOS application for Apple Watch Ultra 2 that continuously monitors heart rate during non-sporting activities, such as driving.
The application uses:
● HKWorkoutSession
● HKLiveWorkoutBuilder
● HKAnchoredObjectQuery to retrieve heart rate samples
I have observed that starting a workout session allows frequent heart rate measurements to continue even when the Apple Watch display becomes dimmed.
However, this creates an unwanted side effect: although the user is not exercising, the session contributes to the Activity rings.
In my tests, a workout recorded as type .other generated Exercise Minutes and Active Energy, even though the saved workout itself reported 0 active calories.
The problem occurs when deleting the workout.
After selecting Delete Workout & Data in the Health/Fitness interface:
1. The workout disappears from the workout history.
2. The Exercise Minutes generated during the session remain in HealthKit.
3. The Active Energy samples generated during the same interval also remain.
4. The corresponding Activity ring totals are not immediately corrected.
I subsequently deleted the Exercise Minutes samples manually from the Health app.
This corrected the numerical Exercise Minutes total.
The Active Energy samples required separate handling.
In some tests, the numerical values and the graphical representation of the Activity rings also appeared temporarily inconsistent.
My questions are:
1. Is this the expected behavior of HealthKit when deleting a workout created using HKWorkoutSession and HKLiveWorkoutBuilder?
2. Why does Delete Workout & Data leave Exercise Minutes and Active Energy samples generated during the workout interval?
3. Are these samples considered independent system-generated measurements rather than data associated with the workout?
4. Is there a supported way to prevent a monitoring session from contributing to the Activity rings while still maintaining frequent heart rate acquisition in the background?
My objective is to monitor physiological parameters during activities that are not exercise, without modifying the user’s fitness statistics.
I would appreciate clarification about the intended behavior of these APIs and the recommended implementation approach.
2
0
80