Getting Started
설치 단계와 이 플러그인의 전체 마크다운 가이드를 포함하는 설정 프롬프트를 복사하세요.
Set up this Capacitor plugin in the project.
Use the package manager already used by the project.
Install these package(s): `@capgo/capacitor-device-info`
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/device-info/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.
호환성
호환성@capgo/capacitor-device-info requires Capacitor 8 이상 (@capacitor/core >=8.0.0).
설치
설치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-device-info` plugin in my project.수동 설치를 위해 패키지를 설치하고 네이티브 프로젝트를 동기화하세요:
npm install @capgo/capacitor-device-infonpx cap syncimport
import 섹션import { DeviceInfo } from '@capgo/capacitor-device-info';스냅샷 한 번 읽기
스냅샷 한 번 읽기 섹션const snapshot = await DeviceInfo.getInfo();
console.log(snapshot.cpu.cores);console.log(snapshot.memory.usedPercent);console.log(snapshot.storage.freeBytes);console.log(snapshot.sensors?.pressureHpa);cpu.usagePercent delta 기반입니다. 첫 번째 네이티브 샘플에서는 생략할 수 있습니다; 두 번째 샘플 이후 CPU 사용률이 채워진 것을 받으려면 다시 호출하거나 모니터링을 사용하세요. getInfo() 스트림 업데이트
스트림 업데이트 섹션
복사const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => { console.log(sample.sequence, sample.elapsedMs); console.log(sample.cpu.usagePercent); console.log(sample.sensors?.readings);});
const session = await DeviceInfo.startMonitoring({ intervalMs: 1000, emitImmediately: true,});
console.log(session.intervalMs, session.startedAt);섹션 제목 “모니터링 동작”
기본값으로intervalMs밀리초입니다. 아래의1000밀리초는250기본값으로250.emitImmediatelydefaults totrue.- 설정
durationMs또는sampleCount자동으로 모니터링을 중단합니다. - 호출
startMonitoring()모니터링이 활성화된 상태에서 다시 시작하면 새로운 옵션과 함께 세션을 재시작합니다. - 모두
deviceInfoUpdate1부터 시작하는sequence, 세션의startedAt타임스탬프, 그리고elapsedMs.
업데이트를 중단하고 리스너를 제거합니다.
업데이트를 중단하고 리스너를 제거하는 방법await DeviceInfo.stopMonitoring();await handle.remove();
// Or remove every listener registered on this plugin:await DeviceInfo.removeAllListeners();모니터링 상태 확인
모니터링 상태 확인const state = await DeviceInfo.isMonitoring();
if (state.monitoring) { console.log(state.samplesEmitted);}센서 필드 온보딩
센서 필드 온보딩const { sensors, cpu, gpu } = await DeviceInfo.getInfo();
console.log(cpu.temperatureCelsius);console.log(gpu?.temperatureCelsius);console.log(sensors?.batteryTemperatureCelsius);console.log(sensors?.ambientTemperatureCelsius);console.log(sensors?.relativeHumidityPercent);console.log(sensors?.pressureHpa);console.log(sensors?.illuminanceLux);console.log(sensors?.proximityDistanceCm);console.log(sensors?.availableSensors);센서 필드는 선택 사항입니다. 기기, OS, 앱 샌드박스에서 노출하는 메트릭이 있는 경우에만 표시됩니다.
플랫폼 참고
플랫폼 참고- iOS는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CoreMotion 센서 가용성만 보고하지만 raw CPU 또는 GPU 온도는 보고하지 않습니다.
- Android는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CPU 및 GPU 온도는 최적의 노력으로 열 영역 읽기를 수행합니다.
- 웹 지원은 최적의 노력이며 브라우저가 원시 기기 센서를 일관되게 노출하지 않기 때문에 비어 있는 온보딩 센서 배열을 보고합니다.
API 참조
API 참조 섹션| 메서드 | 반환 | 주의 |
|---|---|---|
getInfo() | Promise<DeviceInfoSnapshot> | 현재 스냅샷을 읽습니다. |
startMonitoring(options?) | Promise<StartMonitoringResult> | 주기적인 스냅샷을 시작하거나, 활성 세션을 새로운 옵션으로 재시작합니다. |
stopMonitoring() | Promise<StopMonitoringResult> | 활성 세션을 중지합니다. |
isMonitoring() | Promise<MonitoringState> | 현재 세션 상태를 반환합니다. |
addListener('deviceInfoUpdate', listener) | Promise<PluginListenerHandle> | 주기적인 스냅샷 리스너를 등록합니다. |
removeAllListeners() | Promise<void> | 등록된 모든 리스너를 제거합니다. |
getPluginVersion() | Promise<PluginVersionResult> | 네이티브 플러그인 버전을 읽습니다. |
PluginListenerHandle Capacitor에서 제공하는 것은 remove() 해당 개별 리스너를 제거하는 데
Snapshot 종류
Snapshot 종류interface CpuInfo { cores: number; activeCores?: number; architecture?: string; model?: string; usagePercent?: number | null; maxFrequencyHz?: number; temperatureCelsius?: number;}
interface MemoryInfo { totalBytes?: number; freeBytes?: number; usedBytes?: number; usedPercent?: number; appUsedBytes?: number; appLimitBytes?: number; lowMemory?: boolean; pressure?: 'normal' | 'warning' | 'critical' | 'unknown';}
interface StorageInfo { totalBytes?: number; freeBytes?: number; usedBytes?: number; usedPercent?: number;}
interface GpuInfo { api?: 'metal' | 'opengl' | 'webgl' | 'unknown'; vendor?: string; renderer?: string; version?: string; maxTextureSize?: number; temperatureCelsius?: number;}
type ThermalState = 'nominal' | 'fair' | 'serious' | 'critical' | 'unknown';
interface DeviceInfoSnapshot { timestamp: number; platform: 'ios' | 'android' | 'web'; cpu: CpuInfo; memory: MemoryInfo; storage: StorageInfo; gpu?: GpuInfo; thermalState?: ThermalState; lowPowerMode?: boolean; sensors?: OnboardSensorsInfo;}크기 값은 바이트로 표시되며, maxFrequencyHz 주파수는 Hz, 온도 값은 섭씨로 표시됩니다. usagePercent 이 될 수 있습니다. null 플랫폼이 충분한 샘플을 계산할 때까지
센서 종류
센서 종류interface OnboardSensorDescriptor { type: string; name?: string; vendor?: string; platformType?: number; maximumRange?: number; resolution?: number; powerMilliamp?: number; minDelayMicroseconds?: number; wakeUp?: boolean;}
interface OnboardSensorReading { type: string; unit: string; value: number; name?: string; timestamp?: number;}
interface OnboardSensorsInfo { availableSensors?: OnboardSensorDescriptor[]; readings?: OnboardSensorReading[]; batteryTemperatureCelsius?: number; ambientTemperatureCelsius?: number; relativeHumidityPercent?: number; pressureHpa?: number; illuminanceLux?: number; proximityDistanceCm?: number;}Unix epoch 밀리초는 센서 읽기 시간입니다. 일반적인 단위는 섭씨, 백분율, hPa, 라っく스, 센티미터입니다.
모니터링 유형
모니터링 유형interface MonitoringOptions { intervalMs?: number; durationMs?: number; sampleCount?: number; emitImmediately?: boolean;}
interface StartMonitoringResult { monitoring: boolean; intervalMs: number; startedAt: number;}
interface StopMonitoringResult { monitoring: boolean;}
interface MonitoringState { monitoring: boolean; intervalMs?: number; startedAt?: number; samplesEmitted?: number;}
interface DeviceInfoUpdate extends DeviceInfoSnapshot { sequence: number; startedAt: number; elapsedMs: number;}
interface PluginVersionResult { version: string;}startedAt, timestamp, elapsedMs 밀리초입니다. sequence 각 모니터링 세션에서 시작됩니다. 1 진실의 근원
This reference follows the public API in the plugin’s src/definitions.ts진실의 근원
시작하기에서 계속
시작하기에서 계속이러한 장치 진단을 위해 시작하기 Capacitor와 함께 사용하는 경우 @capgo/capacitor-device-info Capacitor와 함께 사용하는 경우 Capacitor와 함께 사용하는 @capgo/capacitor-device-info Capacitor와 함께 사용하는 경우 Capacitor와 함께 사용하는 @capgo/capacitor-barometer Capacitor와 함께 사용하는 경우 Capacitor와 함께 사용하는 @capgo/capacitor-light-sensor 빛 센서 읽기 위해 초점을 맞춘.