컨텐츠로 바로가기

Getting Started

설치

설치
터미널 창
bun add @capgo/capacitor-health
bunx cap sync

import

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

API Overview

API 개요

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

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

requestAuthorization

__CAPGO_KEEP_0__ 권한 요청

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

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

사용자에게 권한을 요청하지 않고 제공된 데이터 유형의 권한 상태를 확인합니다.

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

지정된 시간 범위 내에서 지정된 데이터 유형의 샘플을 읽습니다.

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

native 건강 저장소에 단일 샘플을 씁니다.

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

openHealthConnectSettings

openHealthConnectSettings 섹션

iOS 이외의 Android에서만 건강 연결 설정 화면을 엽니다. iOS 에서 이 메서드는 아무것도 하지 않습니다.

사용자들이 건강 연결 권한을 관리하거나 건강 연결이 설치되지 않았을 때 설치하도록 사용자들을 안내하는 데 사용하세요.

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

showPrivacyPolicy

showPrivacyPolicy 섹션

iOS 이외의 Android에서만 앱의 건강 연결 개인정보 보호 정책을 표시합니다. iOS 에서 이 메서드는 아무것도 하지 않습니다.

이것은 사용자가 권한 대화창에서 “개인정보 보호 정책”을 탭했을 때 건강 연결이 표시하는 개인정보 보호 정책 화면을 표시합니다.

개인정보 보호 정책 URL은 앱의 strings.xml 에 “health_connect_privacy_policy_url”라는 이름의 문자열 리소스를 추가하거나 www/privacypolicy.html 파일을 assets에 두어 구성할 수 있습니다.

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

iOS (HealthKit) 및 Android (Health Connect)에서 지원하는 native 헬스 스토어에서 운동 세션을 조회합니다.

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

queryAggregated

queryAggregated 섹션

native 헬스 스토어에서-aggregated 헬스 데이터를 조회합니다. 시간 단위 (시간, 일, 주, 월)로 데이터를 집계하고 합, 평균, 최소, 최대와 같은 연산을 수행합니다. 대형 날짜 범위에 대한 개별 샘플을 가져올 때보다 효율적입니다.

iOS (HealthKit) 및 Android (Health Connect)에서 지원합니다.

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

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

운동 쿼리 옵션
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;
}
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;
}
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;
}
export interface QueryAggregatedResult {
samples: AggregatedSample[];
}
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';
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. 업스트림에서 변경된 경우 pubilc API을 다시 동기화하세요.

Getting Started에서 계속하세요.

Getting Started에서 계속하세요

__CAPGO_KEEP_0__을 사용하는 경우 Getting Started API과 __CAPGO_KEEP_1__을 연결하여 대시보드와 API 연산을 계획하세요. @capgo/capacitor-health를 사용하여 @capgo/capacitor-health를 사용하여 native capability를 구현하세요. API 개요 API 개요를 사용하여 구현 세부 정보를 확인하세요. 소개 __CAPGO_KEEP_0__ API 키 API 키의 구현 세부 사항, 및 장치 __CAPGO_KEEP_0__ 키의 구현 세부 사항.