Skip to content

Getting Started

GitHub

설치

설치

AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. AI 도구에 Capgo 스킬을 추가하려면 다음 명령어를 사용하세요:

터미널 창
npx skills add https://github.com/Cap-go/capgo-skills --skill capacitor-plugins

다음 명령어를 사용하여 다음 프롬프트를 사용하세요:

Use the `capacitor-plugins` skill from `Cap-go/capgo-skills` to install the `@capgo/capacitor-health` plugin in my project.

Manual Setup을 선호한다면, 플러그인을 설치하기 위해 다음 명령어를 실행하고 아래에 플랫폼별로 설명된 지침을 따르세요:

터미널 창
bun add @capgo/capacitor-health
bunx cap sync
import { Health } from '@capgo/capacitor-health';

현재 플랫폼이 네이티브 SDK를 지원하는지 여부를 반환합니다.

import { Health } from '@capgo/capacitor-health';
await Health.isAvailable();

제공된 데이터 타입에 대해 읽기/쓰기 접근 권한을 요청합니다.

import { Health } from '@capgo/capacitor-health';
await Health.requestAuthorization({} as AuthorizationOptions);

__CAPGO_KEEP_0__ 인증 상태를 확인합니다.

import { Health } from '@capgo/capacitor-health';
await Health.checkAuthorization({} as AuthorizationOptions);

__CAPGO_KEEP_0__를 지정된 시간 범위 내에서 제공된 데이터 유형에 대한 샘플을 읽습니다.

import { Health } from '@capgo/capacitor-health';
await Health.readSamples({} as QueryOptions);

__CAPGO_KEEP_0__를 사용하여 네이티브 헬스 스토어에 샘플을 하나씩 씁니다.

import { Health } from '@capgo/capacitor-health';
await Health.saveSample({} as WriteSampleOptions);

openHealthConnectSettings

__CAPGO_KEEP_0__ 섹션

__CAPGO_KEEP_0__를 사용하여 헬스 커넥트 설정 화면을 엽니다 (안드로이드 전용). iOS에서는 이 메서드는 아무것도 하지 않습니다.

__CAPGO_KEEP_0__를 사용하여 사용자가 헬스 커넥트 권한을 관리하거나 헬스 커넥트를 설치하도록 안내하세요. 헬스 커넥트가 없으면 설치하도록 안내하세요.

import { Health } from '@capgo/capacitor-health';
await Health.openHealthConnectSettings();

showPrivacyPolicy

__CAPGO_KEEP_0__

Health Connect 개인 정보 보호 정책을 표시합니다.

Health Connect의 개인 정보 보호 정책을 표시합니다. iOS에서는 아무런 동작도 하지 않습니다.

Health Connect에서 사용자가 권한 대화 상자에서 '개인 정보 보호 정책'을 탭할 때 표시하는 개인 정보 보호 정책 화면을 표시합니다.

import { Health } from '@capgo/capacitor-health';
await Health.showPrivacyPolicy();

queryWorkouts

복사

__CAPGO_KEEP_0__

import { Health } from '@capgo/capacitor-health';
await Health.queryWorkouts({} as QueryWorkoutsOptions);

복사

__CAPGO_KEEP_0__

import { Health } from '@capgo/capacitor-health';
await Health.queryAggregated({} as QueryAggregatedOptions);

AvailabilityResult

AvailabilityResult 섹션
export interface AvailabilityResult {
available: boolean;
/** Platform specific details (for debugging/diagnostics). */
platform?: 'ios' | 'android' | 'web';
reason?: string;
}

AuthorizationOptions

인증 옵션 섹션
export interface AuthorizationOptions {
/** Data types that should be readable after authorization. */
read?: HealthDataType[];
/** Data types that should be writable after authorization. */
write?: HealthDataType[];
}

AuthorizationStatus

인증 상태 섹션
export interface AuthorizationStatus {
readAuthorized: HealthDataType[];
readDenied: HealthDataType[];
writeAuthorized: HealthDataType[];
writeDenied: HealthDataType[];
}
export interface QueryOptions {
/** The type of data to retrieve from the health store. */
dataType: HealthDataType;
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
startDate?: string;
/** Exclusive ISO 8601 end date (defaults to now). */
endDate?: string;
/** Maximum number of samples to return (defaults to 100). */
limit?: number;
/** Return results sorted ascending by start date (defaults to false). */
ascending?: boolean;
}
export interface ReadSamplesResult {
samples: HealthSample[];
}

WriteSampleOptions

__CAPGO_KEEP_0__
export interface WriteSampleOptions {
dataType: HealthDataType;
value: number;
/**
* Optional unit override. If omitted, the default unit for the data type is used
* (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).
*/
unit?: HealthUnit;
/** ISO 8601 start date for the sample. Defaults to now. */
startDate?: string;
/** ISO 8601 end date for the sample. Defaults to startDate. */
endDate?: string;
/** Metadata key-value pairs forwarded to the native APIs where supported. */
metadata?: Record<string, string>;
/** For blood pressure data, the systolic value in mmHg. Required when dataType is 'bloodPressure'. */
systolic?: number;
/** For blood pressure data, the diastolic value in mmHg. Required when dataType is 'bloodPressure'. */
diastolic?: number;
}

QueryWorkoutsOptions

__CAPGO_KEEP_0__
export interface QueryWorkoutsOptions {
/** Optional workout type filter. If omitted, all workout types are returned. */
workoutType?: WorkoutType;
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
startDate?: string;
/** Exclusive ISO 8601 end date (defaults to now). */
endDate?: string;
/** Maximum number of workouts to return (defaults to 100). */
limit?: number;
/** Return results sorted ascending by start date (defaults to false). */
ascending?: boolean;
/**
* Anchor for pagination. Use the anchor returned from a previous query to continue from that point.
* On iOS, this is the ISO 8601 cursor returned by the previous query. On Android, this uses
* Health Connect's pageToken.
* Omit this parameter to start from the beginning.
*/
anchor?: string;
}

QueryWorkoutsResult

__CAPGO_KEEP_0__
export interface QueryWorkoutsResult {
workouts: Workout[];
/**
* Anchor for the next page of results. Pass this value as the anchor parameter in the next query
* to continue pagination. If undefined or null, there are no more results.
*/
anchor?: string;
}

QueryAggregatedOptions

__CAPGO_KEEP_0__
export interface QueryAggregatedOptions {
/** The type of data to aggregate from the health store. */
dataType: HealthDataType;
/** Inclusive ISO 8601 start date (defaults to now - 1 day). */
startDate?: string;
/** Exclusive ISO 8601 end date (defaults to now). */
endDate?: string;
/** Time bucket for aggregation (defaults to 'day'). */
bucket?: BucketType;
/** Aggregation operation to perform (defaults to 'sum'). */
aggregation?: AggregationType;
}

QueryAggregatedResult

__CAPGO_KEEP_0__
export interface QueryAggregatedResult {
samples: AggregatedSample[];
}

HealthDataType

__CAPGO_KEEP_0__
export type HealthDataType =
| 'steps'
| 'distance'
| 'calories'
| 'heartRate'
| 'weight'
| 'sleep'
| 'respiratoryRate'
| 'oxygenSaturation'
| 'restingHeartRate'
| 'heartRateVariability'
| 'bloodPressure'
| 'bloodGlucose'
| 'bodyTemperature'
| 'height'
| 'flightsClimbed'
| 'exerciseTime'
| 'distanceCycling'
| 'bodyFat'
| 'basalBodyTemperature'
| 'basalCalories'
| 'totalCalories'
| 'mindfulness'
| 'workouts';

HealthSample

HealthSample
export interface HealthSample {
dataType: HealthDataType;
value: number;
unit: HealthUnit;
startDate: string;
endDate: string;
sourceName?: string;
sourceId?: string;
/** Platform-specific unique identifier (HealthKit UUID on iOS, Health Connect metadata ID on Android). */
platformId?: string;
/** For sleep data, indicates the sleep state (e.g., 'asleep', 'awake', 'rem', 'deep', 'light'). */
sleepState?: SleepState;
/** For blood pressure data, the systolic value in mmHg. */
systolic?: number;
/** For blood pressure data, the diastolic value in mmHg. */
diastolic?: number;
}

실질적인 출처

실질적인 출처

이 페이지는 플러그인의 src/definitions.ts공개 API이 업스트림에서 변경될 때 다시 싱크를 실행하세요.

Getting Started에서 계속

Getting Started에서 계속

Capgo를 사용 중이라면 Getting Started 대시보드와 API를 계획하고 운영하기 위해 연결하세요. Using @capgo/capacitor-health capgo의 원시 기능을 위한 Using @capacitor/capgo-health, API 개요 API의 구현 세부 정보를 위한 API 개요, 소개 소개의 구현 세부 정보를 위한 API 키 API 키의 구현 세부 정보를 위한 및 장치 장치의 구현 세부 정보를 위한