更新记录
1.0.0(2026-05-18)
- iOS HealthKit 健康数据读写
- 支持17种健康数据类型
- 样本查询与统计聚合
- 运动/睡眠数据写入
平台兼容性
HealthKit 健康数据管理 - 使用说明
安装
在 HBuilderX 插件市场搜索 szy-healthkit 安装,或手动放入 uni_modules 目录。
基础用法
const health = uni.requireNativePlugin('szy-healthkit')
// 1. 检查设备支持
if (!health.isHealthDataAvailable()) {
console.log('此设备不支持 HealthKit')
return
}
// 2. 请求授权
const ok = await health.requestAuthorization(
['steps', 'heartRate', 'weight', 'height', 'sleep', 'workout'],
['weight', 'height', 'heartRate', 'sleep']
)
// 3. 查询今日步数
const steps = await health.getTodaySteps()
console.log('今日步数:', steps)
// 4. 查询最近心率
const heartRates = await health.getRecentHeartRate(10)
// 5. 写入体重
await health.saveWeight(70.5, new Date().getTime())
支持的数据类型
- 步数(steps)
- 心率(heartRate)
- 距离(distance)
- 卡路里(activeEnergy)
- 体重(weight)
- 身高(height)
- 血压(bloodPressureSystolic / bloodPressureDiastolic)
- 血氧(bloodOxygen)
- 体温(bodyTemperature)
- 爬楼层(flightsClimbed)
- 静息心率(restingHeartRate)
- 步行心率(walkingHeartRateAverage)
- 心率变异性(hrv)
- 睡眠(sleep)
- 正念分钟(mindfulMinutes)
- 运动(workout)
系统权限
需在 manifest.json 中声明:
- NSHealthShareUsageDescription
- NSHealthUpdateUsageDescription
系统要求
- iOS 8.0+
- 仅支持 iPhone / iPad / Apple Watch(模拟器不支持)

收藏人数:
购买普通授权版(
试用
赞赏(0)
下载 16
赞赏 0
下载 11951784
赞赏 1914
赞赏
京公网安备:11010802035340号