I’m developing a watchOS app that records outdoor soccer workouts using HealthKit.
My app starts a workout session with:
HKWorkoutConfiguration.activityType = .soccer
HKWorkoutConfiguration.locationType = .outdoor
HKWorkoutSession
HKLiveWorkoutBuilder
HKLiveWorkoutDataSource
During the workout, I display distance from the live builder statistics:
HKQuantityType.quantityType(forIdentifier: .distanceWalkingRunning)
After the workout ends, I save the workout using finishWorkout(), and later read the saved distance from:
HKWorkout.totalDistance?.doubleValue(for: .meter())
So the total distance shown in my app is not calculated manually from GPS route points. It comes from HealthKit’s workout distance.
I noticed a difference between soccer workouts recorded by Apple’s built-in Workout app and soccer workouts recorded by my third-party watchOS app.
Example comparison:
Apple Workout app soccer:
Active duration: about 88 min
Steps: about 8,832
Distance: about 6.7 km
No visible route/location data in Fitness
My watchOS app soccer:
Active duration: about 87 min
Steps: about 8,998
Distance: about 5.6 km
Includes route/location data
Workout recorded through HKWorkoutSession + HKLiveWorkoutBuilder
Distance read from HKWorkout.totalDistance
The step counts and active durations are very close, but the distance differs by about 1.1 km.
One important detail is that the Apple Workout app soccer workout does not appear to include visible route/location data in Fitness, while my third-party workout does include route/location data. Despite that, the Apple Workout app reports a longer distance.
So the comparison is not simply “GPS route distance vs GPS route distance”. It looks like the built-in Workout app may be estimating soccer distance without exposing route data, while HKLiveWorkoutBuilder for a third-party .soccer workout may be producing a different totalDistance estimate.
My questions are:
When the built-in Apple Workout app records an outdoor soccer workout without exposing route data, how is totalDistance estimated?
Is that distance estimation behavior available to third-party watchOS apps using HKWorkoutSession + HKLiveWorkoutBuilder with .soccer?
If a third-party app records route data for the same soccer activity, can that change how HealthKit calculates totalDistance compared with a no-route built-in Workout app recording?
For third-party soccer workouts, should developers expect HKWorkout.totalDistance to match the built-in Workout app, or is a difference expected?
Is there any additional configuration, entitlement, data type, or best practice required to get more accurate distance estimates for soccer workouts?
Any clarification on the expected behavior would be very helpful.
Thanks!
0
1
40