I have an app that adds cycling workouts to HealthKit. Here is the snippet of code that does it.
let workout = HKWorkout(
activityType: HKWorkoutActivityType.cycling,
start: startTime,
end: endTime,
duration: 0, // compute from start and end data
totalEnergyBurned: HKQuantity(
unit: .largeCalorie(),
doubleValue: Double(calories)
),
totalDistance: HKQuantity(unit: .mile(), doubleValue: distance),
metadata: nil
)
try await store.save(workout)
This successfully adds a workout and the number of calories is recorded in the Health app. However, the iOS Fitness app and the watchOS Activity app do not recognize the calories so the MOVE ring is not affected. What else do I need to do to let those apps know that my workout burned calories?