Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add location and weather information to HealthKit Workout Session

I am working on an app where HealthKit is used and HKWorkout sessions are created and added to the HealthKit store.

Now after I finished an outdoor activity with Apple's native Workout app on the Watch, (like Open Water Swimming), when I then open this workout on the Activity App on my iPhone, it tells me the location where I started the activity and the weather conditions at the time.

I've been reading through the HealthKit documentation but I could not find any API to add this information from my app to the HKWorkoutSession.

Is it possible for developers to add this to a HKWorkout, and if so: how?

Example from Activities App on iPhone

like image 836
Bocaxica Avatar asked Jun 09 '17 09:06

Bocaxica


1 Answers

To add weather details to your app's workouts, you must specify values for the HKMetadataKeyWeatherCondition, HKMetadataKeyWeatherTemperature, or HKMetadataKeyWeatherHumidity metadata keys on the saved HKWorkout. See the metadata keys reference for more information.

There is no API to specify a general location for the workout. However, in watchOS 4.0 your app can now save an HKWorkoutRoute alongside an HKWorkout to provide a map of the route the user took (documentation).

like image 141
Allan Avatar answered Oct 24 '22 07:10

Allan