Having a workout count toward green exercise ring

Not sure if this is the best place to post this, but I couldn't find a dedicated HealthKit forum, so I figure this is best.


I'm creating an app that tracks workouts at the gym. I've created an HKWorkout and set its activity type to HKWorkoutActivityType.TraditionalStrengthTraining. I run my HKWorkoutSession, the calories get counted, and the workout gets logged in the Health app when completed, but the workout time (I tried five minutes) didn't get added to my green exercise ring on my Apple Watch.


It was mentioned in the WWDC keynote that WatchKit apps can contribute to the exercise ring, so I'm wondering if I'm missing something?


Another thing I noticed is that while the HKWorkoutSession is created, and I am able to save it later on, my WatchKit app does not stay in the foreground while the workout session is currently in progress. Perhaps this hasn't been implemented in the first beta?

Replies

Glad I read this, I too am noticing that the workout session is not keeping my app in the foreground. Good to know it's not just me. I will file a bug report for this.

I'm not sure if it's your workout that's the issue, or just with how the green activity ring is tracked in general. I've been logging through Apple's workout app and it seems a 12km outdoor walk up the side of a mountain doesn't count towards the target either.

Same here. My WatchKit app doesn't stay in the foreground even if workout session state is running.

Yeah I have a couple theories on what's going on:


1. It's just not implemented yet, or is buggy, in this first beta

2. Only workouts of a certain HKWorkoutActivityType get counted toward the activity ring

3. I'm missing something


I'm fairly certain it's not #3, since I essentially copied the code presented at the WWDC session on HealthKit, and it *is* logging the workout in HealthKit.


I'm hoping that it's just #1 and not #2, and the next beta (or the one after that) should reveal which one it is.

So I just tried switching the workout type from HKWorkoutActivityType.TraditionalStrengthTraining to HKWorkoutActivityType.Other, and the workout now counts toward the exercise ring. I think this is a really silly distinction: weight training is working out! I'm going to file a bug.

@singy Have you been able to simulate calories and other information in the Watch simulator? Or have you been running your app on a real device?