Is it possible to distinguish real vs manually added running data in HealthKit?

I am developing an iOS application that utilizes running workout data from the iOS Health app / Fitness app via HealthKit, with explicit user permission.

Before finalizing the app design, I would like to clarify several technical aspects related to data reliability, manual entry, record modification, and GPS route availability in HealthKit.

My questions are as follows: 1. Identifying manually added (non-physical) running workouts When a running workout is created in the Health app without actual physical movement (for example, a workout manually added by the user), is there any metadata, flag, or key in HealthKit that allows developers to distinguish these records from workouts generated through actual motion tracking (iPhone or Apple Watch)? 2. Editing existing running workout records Is it possible for users, or for third-party apps with HealthKit write permission, to edit an existing running workout (e.g., distance, duration, calories) after it has been saved? • If edits are allowed, are the original values preserved in any way, or are they fully overwritten? 3. Detecting modified workout records If a running workout (whether originally auto-recorded or manually created) has been edited after creation, is there any identifier, metadata field, source revision, or versioning mechanism in HealthKit that allows developers to detect that the workout has been modified? 4. Access to GPS route / running path data For outdoor running workouts recorded with location services enabled: • Does HealthKit provide access to GPS route data (running paths / location traces) associated with a workout? • Is this route data accessible to third-party apps with user permission? • Is route data available only for workouts recorded on Apple Watch, or also for iPhone-only recordings? • Is there a way to determine programmatically whether a running workout includes valid GPS route data?

The overall goal is to understand whether, when building an app that relies on HealthKit running data, it is technically possible to differentiate motion-based workouts from manually added or edited records, and to assess the availability of route information for outdoor runs.

Any clarification or references to official documentation would be greatly appreciated.

Thank you

I would check out any of the HealthKit WWDC talks.

  1. There is a 'user entered' metadata key, but that relies on the app to use that flag when the user saves a workout.
  2. You can't edit samples. You can only create new ones, or delete data from your app.
  3. Hard to answer, are you trying to sync the data with a backend or just present changes locally to the user? There are version metadata keys that will be mutated by Apple. Again, up to the third party developer to do the right thing.
  4. This one is fairly obvious if you check the docs or watch some old videos. Checkout the route builder and route query types. Ask for workout route permissions and you can query any route against workouts. Do note you can have more than one route per workout. As to will route data exist? That depends on the app that saved the workout. Apple does this for outdoor workouts.

Aside from 'delete all records of all apps', you app should be able to do almost everything that Apple Fitness and Apple Health allow. When deleting data, you can only delete data that you created. This is there to prevent an app with a bug that wipes out the users whole health database.

https://developer.apple.com/videos/all-videos/?topic=health%20%26%20fitness

Is it possible to distinguish real vs manually added running data in HealthKit?
 
 
Q