指南
关于健康的教程
使用 @capgo/capacitor-health
Capacitor 插件用于与 Apple HealthKit 和 Health Connect 的数据进行交互。
安装
bun add @capgo/capacitor-health
bunx cap sync
本插件暴露的内容
isAvailable- 检查当前平台是否支持本地健康 SDK.requestAuthorization- 请求对提供的数据类型进行读写访问。checkAuthorization- 检查提供的数据类型的授权状态而不提示用户。readSamples- 在指定时间范围内读取给定数据类型的样本。
示例用法
isAvailable
检查当前平台是否支持本地健康 SDK.
import { Health } from '@capgo/capacitor-health';
await Health.isAvailable();
requestAuthorization
请求对提供的数据类型进行读写访问。
import { Health } from '@capgo/capacitor-health';
await Health.requestAuthorization({} as AuthorizationOptions);
checkAuthorization
检查提供的数据类型的授权状态而不提示用户。
import { Health } from '@capgo/capacitor-health';
await Health.checkAuthorization({} as AuthorizationOptions);
readSamples
在指定时间范围内读取给定数据类型的样本。
import { Health } from '@capgo/capacitor-health';
await Health.readSamples({} as QueryOptions);
完整参考
- GitHub: https://github.com/Cap-go/capacitor-health/
- 文档:/docs/plugins/health/
继续使用@capgo/capacitor-health
如果您正在使用 使用@capgo/capacitor-health 来规划原生插件工作,连接它与 @capgo/capacitor-health 了解@capgo/capacitor-health的实现细节 开始使用 了解开始使用的实现细节 Capgo 插件目录 了解Capgo 插件目录中的产品工作流程 Capacitor 插件由 Capgo 提供 了解 Capacitor 插件由 Capgo 的实现细节 添加或更新插件 了解添加或更新插件的实现细节