IOS – How does HealthKit resolve recording of the same activity by multiple sources

health-kithealth.appios

What happens when more than one "source" registered with HealthKit tracks the same activity?

For example, if I have Human tracking my activity in general, and then use Cyclemeter (which supports HealthKit in version 10.3) to track particular bike ride, both will (I assume) submit the same activity to HealthKit. Presumably it should be possible for HealthKit to recognize that these activities are likely duplicates and at least ask me how to resolve the "duplication" (much as sync conflicts are resolved). In fact, the activities contain enough data that such recognition should generally be possible to perform automatically.

Does HealthKit do this? Does it resolve duplicate recordings of the same activity (either automatically or semi-automatically)?

Best Answer

HealthKit is pretty smart with your data. For every source in the Health app, you can set the priority of difference apps. Tap one of the metrics in the Health app tap Share data > Edit to drag sources in the right order.

If other apps request data, HealthKit will automatically merge the datasets, probably based on timestamps. It picks the high priority app first, and fills the gaps in data with the number 2 app, etc.

This WWDC would be a great start to get a complete overview.