跳过主要内容
返回到插件
@capgo/capacitor-健康
教程
@capgo/capacitor-健康

健康

从本机健康平台获取健康和健身数据

指南

健康教程

在设备上测试

Download the Capgo app, then scan the QR code.

健康插件预览二维码code

使用@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

Requests read/write access to the provided data types.

import { Health } from '@capgo/capacitor-health';

await Health.requestAuthorization({} as AuthorizationOptions);

checkAuthorization

Checks authorization status for the provided data types without prompting the user.

import { Health } from '@capgo/capacitor-health';

await Health.checkAuthorization({} as AuthorizationOptions);

readSamples

Reads samples for the given data type within the specified time frame.

import { Health } from '@capgo/capacitor-health';

await Health.readSamples({} as QueryOptions);

全局参考

继续使用@capgo/capacitor-health

如果您正在使用 使用@capgo/capacitor-health 规划原生插件工作时,连接它与 @capgo/capacitor-health 为 @capgo/capacitor-health 的实现细节, 开始使用 为 Getting Started 的实现细节, Capgo 插件目录 为 Capgo 插件目录中的产品工作流程, Capacitor 插件由 Capgo 提供 为 Capacitor 插件由 Capgo 提供的实现细节,并且 添加或更新插件 为添加或更新插件的实现细节。