WorkoutKit: Alert - HeartRateZoneAlert vs PowerZoneAlert

Hello, I'm trying to understand what's the difference between:

  • HeartRateZoneAlert: static func heartRate(zone: Int) -> Self
  • PowerZoneAlert : static func power(zone: Int) -> Self

And also, why HeartRate alerts support range, but Power doesn't support Range?

Replies

There is a difference between power and a Heartrate. Your power is for example the watts you produce when your are cycling. You can also set a zone for a power zone:

let powerMinValue = HKQuantity(unit .watt(), doubleValue: 250)
let powerMaxValue = HKQuantity(unit .watt(), doubleValue: 270)
let powerRange: WorkoutTargetType = .range(min: powerMinValue, max: powerMaxValue)
let powerAlert = WorkoutAlert(type: .currentPower, target: powerRange)

This can be seen on on this WWDC video

  • @tmiedema93 API you're talking about is not available in iOS 17. Apple doesn't use enums for WorkoutAlert yet. I see they updated their WWDC session ahead for upcoming changes in iOS 17.1. It looks like in iOS 17.1 they will roll out breaking changes for WorkoutKit without backward compatibility. Also currently I see the problems with Power Alerts in Running workouts - they don't work at all.

  • @Glebus did you see changes in iOS 17.1? I'm building for iOS 17.1 and no breaking changes in the API compared to ios 17.

Add a Comment