Add location and weather information to your HealthKit training session

I am working on an application that uses HealthKit

and HKWorkout

sessions are created and added to the store HealthKit

.

Now after I have finished my outdoor workout using the Apple Natural Workout app on my Watch (like Open Water Swimming), when I open this workout in the Activity app on my iPhone, it tells me where I started my activity and the weather conditions at the time.

I was reading the documentation HealthKit

, but I couldn't find an API to add this information from my application to HKWorkoutSession

.

Is it possible for the developers to add this to HKWorkout

, and if so: how?

Example from App on iPhone

+3


source to share


1 answer


To add weather data to workout apps, you must specify values ​​for metadata HKMetadataKeyWeatherCondition

, HKMetadataKeyWeatherTemperature

or HKMetadataKeyWeatherHumidity

for saved data HKWorkout

. For more information, see the metadata link .



There is no API for specifying a general workout location. However, in watchOS 4.0, your app can now save HKWorkoutRoute

along with HKWorkout

to provide a route map that the user took ( documentation ).

+4


source







All Articles