3

Workouts recorded by Apple Workouts app on Apple Watch assign a location to stationary workouts, which is displayed as a pin in the Apple Fitness app.

enter image description here

This does not seem to be a HKWorkoutRoute (displayed as a route heatmap in Apple Fitness), which is used for workouts that have moved (such as cycling or running), as trying to load the HKWorkoutRoute for this workout leads to an empty list.

It's not a workout metadata either (like weather and humidity are). The documentation from Apple only offers guidance on HKWorkoutRoutes and not this singular location property.

How is this single location added to workouts from Apple Workouts, how can I as a developer read the location to display a map with a pin in my app, and how can I as a developer assign a location to the workouts I am writing to Apple Health, to ensure the best interoperability with Apple Fitness and other apps reading my workout type?

Empty2k12
  • 475
  • 12
  • 34
  • @Magnas This question is about attaching a GPS location obtained through core-location to a HealthKit workout, not how to get a GPS location. – Empty2k12 Oct 30 '21 at 10:56
  • I guess you figured it out, but you can add anything to metadata, like a latitude and a longitude, and maybe a string with an actual address. But sadly there is still not a way to access the location stored by Apple's Fitness app. – Laszlo May 29 '23 at 09:18

1 Answers1

3

This is stored/used by Workout/Fitness apps and isn't available as API. You can try storing a workout route with a single location to get effectively the same behaviour for your app.

psolanki
  • 381
  • 1
  • 2
  • 1
    Thanks for your answer. Sadly, this does not make my app interoperable with Fitness and other apps. I wish there was a standard for storing the workout location that both Apple and developers adhere to. Worth opening a Feedback? – Empty2k12 Nov 11 '21 at 16:02
  • Yes, please file a feedback. How does it look if you do save a workout route with just one location? It may look different from what Fitness shows for Watch workouts but is it not feasible? – psolanki Nov 12 '21 at 17:08
  • 2
    This is a great use case for HealthKit metadata fields. You could use this instead of a HKWorkoutRoute with a single coordinate for your own implementation. It would be nice if Apple provided a global metadata key to standardize this and expose their hidden location value, similar to `HKMetadataKeyTimeZone` etc. – Mike Mertsock Nov 22 '21 at 14:09