Some of my workouts that I tracked with my AppleWatch do have the information about elevation gain in them. Some also show me the max and min altitude of the workout.
I also have an app to track workouts and would like to know how to add this information. I was going through HKQuantityTypeIdentifier but could not find anything useful there. Then I had a look at HKWorkoutRouteBuilder which has a metadata dictionary, but also couldn't find any relevant keys there.
Does anybody know how to add information like max/min altitude and the elevation gain to my workouts in HealthKit?
These are the only metadata keys related to elevation that can be added to a workout in HealthKit:
HKMetadataKeyElevationAscendedHKMetadataKeyElevationDescendedThe numbers for elevation gain, min, and max might be referring to the information shown in the Activity app for workouts that are recorded with the built-in Apple Watch Workouts app (e.g. running, cycling, walking workouts). As far as I know there's no way to add that info from another app using the available Health APIs.
If you compare what the Activity app shows and what the Health shows for that same workout, you can see the Activity app has other info not shown in the HealthKit metadata.