Aggregated CMPedometerData (iPhone + Watch total count)

对着背影说爱祢 提交于 2019-12-18 09:47:11

问题


My app collects CMPedometerData both on the iPhone and the Watch.

iPhone's steps number (both in real time and historical data) are significantly lower than those recorded by the Watch (witch makes sense, since "on device" steps are actually lower when you always wear the Watch while sometimes leaving the phone on the desk).

The fact is, the Watch seems to have the aggregated data, or at least since it's the higher step count the most significant data, so I'd like to have those aggregated / higher data on the iPhone app too.

Do I need to collect them on both devices and merge them manually? Is there a way to get the aggregated data from CMPedometer, since Apple is already doing the merge behind the scenes?

Thanks in advance!


回答1:


HealthKit uses HKStatisticsQuery and HKStatisticsCollectionQuery to compute the aggregated step count from several devices. These methods automatically detect overlaps in the measurements and get rid of the duplicate entries.

You can find some sample in in the official documentation of HKStatisticsQuery.



来源:https://stackoverflow.com/questions/44580730/aggregated-cmpedometerdata-iphone-watch-total-count

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!