Workouts fail to register on Fitness activity rings

Hello,

My app syncs workout data from a third-party device and records workouts with HealthKit as follows:

let builder = HKWorkoutBuilder(healthStore: healthStore, configuration: hkConf, device: hkDevice)
try await builder.beginCollection(at: startDate)
try await builder.addSamples(samples)
try await builder.endCollection(at: endDate)
let workout = try await builder.finishWorkout()

let workoutRouteBuilder = HKWorkoutRouteBuilder(healthStore: healthStore, device: hkDevice)
try await workoutRouteBuilder.insertRouteData(filteredLocations)
try await workoutRouteBuilder.finishRoute(with: workout, metadata: nil)

However, I’m encountering two issues:

  1. The workouts appear in Apple Fitness but do not contribute to the activity rings.
  2. The workout includes a route (visible in the raw workout data in Apple Health) but does not display on Apple Fitness.

Is there any way to fix this? I’d appreciate any suggestions you might have.

__

You can take a look at the following post as I provided a workable code example that can update the activity rings there:

Regarding the workout route issue, it is typically because the route data has something wrong. One example is that the timestamps in the track points of the route are not set or are not consistent with the workout start / end time.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Thank you, Ziqiao, your example helped me trace the issue after a lot of trial and error.

Regarding appleExerciseTime (and other apple* types), it seemed to me like those types are reserved for the Apple Watch, is that correct?

If so, is there any way for me as a 3rd party app+accessory to make the other activity rings show or affect them in any way without an Apple Watch?

Workouts fail to register on Fitness activity rings
 
 
Q