健康__CAPGO_KEEP_0__插件:安装、设置与示例
返回插件
@capgo/capacitor-health
教程
@capgo/capacitor-health

健康

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

指南

健康教程

在设备上测试

下载Capgo应用,扫描QRcode

Health plugin preview QR code

Using @capgo/capacitor-health

Capacitor plugin to interact with data from Apple HealthKit and Health Connect.

安装

bun add @capgo/capacitor-health
bunx cap sync

此插件暴露的内容

  • isAvailable - Returns whether the current platform supports the native health SDK.
  • requestAuthorization - 请求对提供的数据类型的读写访问。
  • checkAuthorization - 检查用户未被提示的提供数据类型的授权状态。
  • readSamples - 在指定时间范围内读取给定数据类型的样本。

示例用法

isAvailable

Returns whether the current platform supports the native health 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);

全局参考

继续使用@capgo/capacitor-health

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