Workout Effort Scores

Is there anywhere that describes in detail how third party workout apps can use the new effort score functionality? I can't see much in the documentation or any of the WWDC videos.

In particular it would be useful to know if an effort score is automatically calculated for workouts created with third party apps? It doesn't seem to happen but some people say it takes weeks / months before watchOS starts calculating it for third party apps.

If it doesn't happen automatically then how can the app set it? I tried the new relateWorkoutEffortSample API but that didn't work for me (see https://developer.apple.com/forums/thread/763539).

If I could get it working then how should I determine a default effort score based on the workout metrics? Is that something that the app should do? If so then it would be good to be consistent with watchOS so some idea of how that is calculating effort scores would be useful.

Sorry for all the questions, especially if there is an article in the documentation or a video that I have missed.

Answered by DTS Engineer in 807062022

OK, I should have made this clear in my previous post – Although I described the behavior the system "is supposed to" have, I haven't seen the metric in my Fitness.app or Health.app. I don't find a .estimatedWorkoutEffortScore sample for my workout in my HealthKit store either.

I hence would suggest that you file a feedback report to get attentions from the HealthKit team – If you do so, please share your report ID here for folks to track.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

The system is supposed to create estimated workout effort scores (.estimatedWorkoutEffortScore) for certain workout types. As of today, the types include walking, running, hiking, and cycling. If you don't see that happens, I’d suggest that you file a feedback report and share your report ID here.

For .workoutEffortScore, you need to create your own sample and relate it to a workout, as discussed in Adding workoutEffortScore to HKWorkout.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

I don't see estimated effort scores in Apple's Fitness app for any workouts created by my app, for any activity type.

The only time they are visible is if an effort score has been specifically set by the app (which I got working after your help on that other thread, so thanks for that).

I am assuming that the Fitness app shows the effort if one has been set and otherwise shows the estimated effort. Is that the case?

Or does the estimated effort get stored in Health Kit but is not used by the Fitness app?

Accepted Answer

OK, I should have made this clear in my previous post – Although I described the behavior the system "is supposed to" have, I haven't seen the metric in my Fitness.app or Health.app. I don't find a .estimatedWorkoutEffortScore sample for my workout in my HealthKit store either.

I hence would suggest that you file a feedback report to get attentions from the HealthKit team – If you do so, please share your report ID here for folks to track.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

As for which types support this capability, check out the HKLiveWorkoutDataSource and inspect the types to collect property. You'll find that the types described by @DTS Engineer are consistent with this approach to double check.

Looking at a workout that Apple Activity app recorded, the 'effort sample' start and stop date are consistent with the workout duration.

Estimated effort score (3). Start 9:08:21 PM End 9:32:15 PM Saved 9:32:15 PM

Workout Start 9:08:20 PM End 9:32:15 PM Saved 9:32:20 PM

If I find some time I'll inspect the milliseconds for these dates and identify the exact order.

I'm curious of there is a timing issue between stopping a workout session, stopping the builder, and ending the session. Like it generates a sample AFTER the builder collection has completed and then gets dropped. It is not exactly easy to record a real workout with the debugger attached or firing up console to sniff out logs. I plan to rewrite all of my code using the async flavor of the APIs where possible instead of nested closures to see if that makes a difference. I can't wait for HKWorkoutSession and HKWorkoutBuilder to be actors and fully async (hopefully in the future)!

FB15315876 - Documentation / HealthKit: Publish documentation about .workoutEffortScore and .estimatedWorkoutEffortScore

Workout Effort Scores
 
 
Q