CMPedometer's steps history is different than the Health App

968 Views Asked by At

I am retrieving the past 7 days using CMPedometer's method : queryPedometerDataFromDate:toDate:withHandler: but the results are different that the Health App, and our users are complaining, of course.

Here are the result from the query : ( iPhone 6s )

startDate 2017-12-09 23:00:00 +0000 to endDate : 2017-12-10 22:59:59 +0000 - numberOfSteps 472 - distance 326 != 3203 steps, 3.8km

startDate : 2017-12-10 23:00:00 +0000 to endDate : 2017-12-11 22:59:59 +0000 - numberOfSteps 606 - distance 448 != 3906 steps, 3.7

startDate : 2017-12-11 23:00:00 +0000 to endDate : 2017-12-12 22:59:59 +0000 - numberOfSteps 3903 - distance 2987 ~= 3905 steps, 2.9km

startDate : 2017-12-12 23:00:00 +0000 to endDate : 2017-12-13 22:59:59 +0000 - numberOfSteps 25624 - distance 17938 ~= 25633 steps, 17.9km

startDate : 2017-12-13 23:00:00 +0000 to endDate : 2017-12-14 22:59:59 +0000 - numberOfSteps 3842 - distance 2598 ~= 3831 steps, 2.5km

I am noooo clue why this is going on.

1

There are 1 best solutions below

2
On

CoreMotion only has step counts recorded by the device your app is running on. If your users have Apple Watches or use other HealthKit enabled apps to record step counts, the aggregated values from HealthKit may be significantly different than those from CoreMotion. If what you want is to display the same step counts shown in the Health app, you should use HealthKit's HKStatisticsQuery or HKStatisticsCollectionQuery.