진실의 근원
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-health`
Run the required Capacitor sync/update step after installation.
Read this markdown guide for the full setup steps: https://raw.githubusercontent.com/Cap-go/website/refs/heads/main/apps/docs/src/content/docs/docs/plugins/health/getting-started.mdx
Use that guide for platform-specific steps, native file edits, permissions, config changes, imports, and usage setup.
If that guide references other docs pages, read them too.
설치
설치AI-Assisted Setup을 사용하여 플러그인을 설치할 수 있습니다. Capgo 스킬을 AI 도구에 추가하려면 다음 명령어를 사용하세요:
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-healthbunx cap syncimport { Health } from '@capgo/capacitor-health';API 개요
API 개요isAvailable
__CAPGO_KEEP_0__ 지원 여부SDK 지원 여부
import { Health } from '@capgo/capacitor-health';
await Health.isAvailable();requestAuthorization
__CAPGO_KEEP_0__ 권한 요청__CAPGO_KEEP_0__ 제공 데이터 유형에 대한 읽기/쓰기 접근을 요청합니다.
import { Health } from '@capgo/capacitor-health';
await Health.requestAuthorization({} as AuthorizationOptions);checkAuthorization
__CAPGO_KEEP_0__ 권한 확인__CAPGO_KEEP_0__ 제공 데이터 유형에 대한 사용자에게 권한을 요청하지 않고 권한 상태를 확인합니다.
import { Health } from '@capgo/capacitor-health';
await Health.checkAuthorization({} as AuthorizationOptions);readSamples
__CAPGO_KEEP_1____CAPGO_KEEP_2__
import { Health } from '@capgo/capacitor-health';
await Health.readSamples({} as QueryOptions);saveSample
__CAPGO_KEEP_1____CAPGO_KEEP_3__
import { Health } from '@capgo/capacitor-health';
await Health.saveSample({} as WriteSampleOptions);openHealthConnectSettings
__CAPGO_KEEP_4____CAPGO_KEEP_5__
__CAPGO_KEEP_6__
import { Health } from '@capgo/capacitor-health';
await Health.openHealthConnectSettings();showPrivacyPolicy
__CAPGO_KEEP_7__Shows the app’s privacy policy for Health Connect (Android only). On iOS, this method does nothing.
This displays the same privacy policy screen that Health Connect shows when the user taps “Privacy policy” in the permissions dialog.
The privacy policy URL can be configured by adding a string resource named “health_connect_privacy_policy_url” in your app’s strings.xml, or by placing an HTML file at www/privacypolicy.html in your assets.
import { Health } from '@capgo/capacitor-health';
await Health.showPrivacyPolicy();queryWorkouts
Section titled “queryWorkouts”Health Connect native 저장소에서 운동 세션을 조회합니다. iOS (HealthKit)와 Android (Health Connect)에서 지원됩니다.
import { Health } from '@capgo/capacitor-health';
await Health.queryWorkouts({} as QueryWorkoutsOptions);queryAggregated
Section titled “queryAggregated”Health Connect native 저장소에서 집계된 건강 데이터를 조회합니다. 시간 단위 (시간, 일, 주, 월)로 데이터를 집계하고 합, 평균, 최소, 최대와 같은 연산을 수행합니다. 대량의 날짜 범위에 대한 개별 샘플을 가져오기보다 효율적입니다.
iOS (HealthKit)와 Android (Health Connect)에서 지원됩니다.
import { Health } from '@capgo/capacitor-health';
await Health.queryAggregated({} as QueryAggregatedOptions);Type Reference
타입 참조 섹션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[];}QueryOptions
쿼리 옵션 섹션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;}ReadSamplesResult
읽기 샘플 결과 섹션export interface ReadSamplesResult { samples: HealthSample[];}WriteSampleOptions
쓰기 샘플 옵션 섹션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_1__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_2__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_3__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_4__export interface QueryAggregatedResult { samples: AggregatedSample[];}HealthDataType
__CAPGO_KEEP_5__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
__CAPGO_KEEP_6__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;}실질적 진실
Source Of Truth 섹션이 페이지는 플러그인의 src/definitions.ts. upstream에서 변경된 경우 public API를 다시 동기화하세요.
Getting Started에서 계속
Keep going from Getting Started 섹션Capgo를 사용 중이라면 Getting Started dashboard 및 API를 계획하고 운영하기 위해 연결하세요. @capgo/capacitor-health를 사용하여 @capgo/capacitor-health를 사용하여 native capability를 사용합니다. API 개요 API 개요의 구현 세부 정보를 위해 소개 소개의 구현 세부 정보를 위해 API 키 API 키의 구현 세부 정보를 위해, 및 장치 장치의 구현 세부 정보를 위해.