统计数据接口
更新时间:
了解如何操作统计数据 Statistics 通过本节,您将学会
查询以及监听 Statistics
下面通过血氧的示例来说明如何使用当天的数据统计接口
获取当天血氧的最小值
import health from '@service.health'
health.getTodayStatistic({
dataType: health.DATA_TYPES.SPO2,
statisticType: health.STATISTIC_TYPES.MIN
success: (res) => {
console.log('今天的血氧最小值统计的开始时间为:', res.startTime,'结束时间为:', res.endTime)
console.log('今天的血氧最小值为', res.value)
}
})
复制代码
监听当天的血氧最小值的变化
import health from '@service.health'
health.subscribeTodayStatistic({
dataType: health.DATA_TYPES.SPO2,
statisticType: health.STATISTIC_TYPES.MIN
callback: (res) => {
console.log('血氧最小值更新为', res.value)
}
})
复制代码
取消监听当天的血氧最小值的变化
import health from '@service.health'
health.unsubscribeTodayStatistic({
dataType: health.DATA_TYPES.SPO2,
})
复制代码