聚合的 CMPedometerData(iPhone + 手表总计数) [英] Aggregated CMPedometerData (iPhone + Watch total count)

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

问题描述

我的应用在 iPhone 和手表上收集 CMPedometerData.

iPhone 的步数(实时数据和历史数据)明显低于 Watch 记录的步数(女巫是有道理的,因为当您始终佩戴 Watch 而有时保持手机开机时,在设备上"的步数实际上更低办公桌).

事实是,Watch 似乎有聚合数据,或者至少因为它是最重要的数据的较高步数,所以 我也希望在 iPhone 应用程序上有这些聚合/更高的数据.

我是否需要在两台设备上收集它们并手动合并它们?有没有办法从 CMPedometer 中获取汇总数据,因为 Apple 已经在幕后进行合并?

提前致谢!

解决方案

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天全站免登陆