汇总CMPedometerData(iPhone +手表总数) [英] Aggregated CMPedometerData (iPhone + Watch total count)

查看:109
本文介绍了汇总CMPedometerData(iPhone +手表总数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序同时在iPhone和Watch上收集 CMPedometerData .

iPhone的步数(实时和历史数据)都明显低于Watch记录的步数(女巫很有意义,因为当您始终佩戴Watch且有时将手机保持开机状态时,在设备上"步数实际上要低一些)桌子).

事实是,Watch似乎具有汇总数据,或者至少是因为更高的步数才是最重要的数据,所以我也希望在iPhone应用程序中也具有这些汇总/更高的数据.

我是否需要在两个设备上收集它们并手动合并它们? 由于苹果已经在幕后进行合并了,因此有办法从CMPedometer中获取汇总数据吗?

提前谢谢!

解决方案

HealthKit使用HKStatisticsQueryHKStatisticsCollectionQuery来计算来自多个设备的汇总步数.这些方法可自动检测测量结果中的重叠并消除重复的条目.

您可以在 HKStatisticsQuery的官方文档中找到一些示例.. >

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!

解决方案

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.

这篇关于汇总CMPedometerData(iPhone +手表总数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆