使用 @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健康 有关@capgo/capacitor健康的实现细节 开始 有关开始的实现细节 Capgo插件目录 有关Capgo插件目录中的产品工作流程 Capacitor由Capgo的插件 有关Capacitor由Capgo的插件的实现细节,并 添加或更新插件 有关添加或更新插件的实现细节。