Step Data Duplication Issue with Apple Health Integration

We are integrating Apple Health step data into our mobile application, Diyetkolik. However, we have received feedback from our users indicating that the step data appears to be significantly higher than expected. After conducting thorough research, we discovered that users who wear a smartwatch are experiencing step data duplication. Both the smartwatch and the phone's step data are being collected and combined, leading to inflated step counts in our application.

We kindly request your assistance in addressing the following issues:

How can we differentiate between step data from the smartwatch and the phone to avoid duplication? Are there best practices or specific APIs we should use to filter and manage step data more accurately? Can you provide guidance on how to implement a solution that ensures accurate step count data for users wearing multiple devices? We appreciate your support in resolving this matter to enhance the accuracy of our application and improve user experience.

Answered by DTS Engineer in 795869022

The HealthKit store contains the data from all sources ( sourceRevision). An Apple Watch, an iPhone, and also any app running on the devices can write Health data to the HealthKit store. If you simply fetch the samples and add them together, yes, the result may be significantly larger then expected because of the duplicate data.

HealthKit provides APIs to address the issue – If you use HKStatisticsQuery to retrieve the steps in a period of time, the result should have been de-duplicated, and should be the same as the one shown in system-provided Health.app. Here is the detail of how to use the API:

You can give it a try and see if it is what you are looking for.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

The HealthKit store contains the data from all sources ( sourceRevision). An Apple Watch, an iPhone, and also any app running on the devices can write Health data to the HealthKit store. If you simply fetch the samples and add them together, yes, the result may be significantly larger then expected because of the duplicate data.

HealthKit provides APIs to address the issue – If you use HKStatisticsQuery to retrieve the steps in a period of time, the result should have been de-duplicated, and should be the same as the one shown in system-provided Health.app. Here is the detail of how to use the API:

You can give it a try and see if it is what you are looking for.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Step Data Duplication Issue with Apple Health Integration
 
 
Q