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.
설치
설치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.Manual Setup을 사용하는 경우, 플러그인을 설치하려면 다음 명령어를 실행하고 아래에 플랫폼에 따라 설명된 지침을 따르세요:
bun add @capgo/capacitor-device-infobunx cap syncImport
임포트import { DeviceInfo } from '@capgo/capacitor-device-info';Copy to clipboard
Read One Snapshotconst 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 Copy to clipboard getInfo Copy to clipboard
is delta-based. The first native sample can omit it; call
다음 샘플이 나올 때까지 다시 호출하거나, CPU 사용률이 채워진 두 번째 샘플을 사용하여const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => { console.log(sample.sequence, sample.elapsedMs); console.log(sample.cpu.usagePercent); console.log(sample.sensors?.readings);});
await DeviceInfo.startMonitoring({ intervalMs: 1000, emitImmediately: true,});스트림 업데이트
자동 업데이트 중지await DeviceInfo.stopMonitoring();await handle.remove();또는 자동으로 중지할 수도 있습니다:
await DeviceInfo.startMonitoring({ intervalMs: 1000, durationMs: 60_000, sampleCount: 60,});모니터링 상태 확인
__CAPGO_KEEP_0__const state = await DeviceInfo.isMonitoring();
if (state.monitoring) { console.log(state.samplesEmitted);}__CAPGO_KEEP_0__
센서 필드는 선택 사항입니다. 기기, OS, 앱 샌드박스에서 노출하는 메트릭이 있을 때만 존재합니다.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);플랫폼 참고 사항
__CAPGO_KEEP_0__
플랫폼 참고 사항- iOS는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CoreMotion 센서 가용성을 보고하지만 raw CPU 또는 GPU 온도는 아닙니다.
- Android는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CPU 및 GPU 온도는 최선의 노력으로 열 영역 읽기를 수행합니다.
- 웹 지원은 최선의 노력으로 브라우저가 원시 장치 센서를 일관되게 노출하지 않기 때문에 비어있는 온보드 센서 배열을 보고합니다.
타입 참조
타입 참조DeviceInfoSnapshot
디바이스 정보 스냅샷export interface DeviceInfoSnapshot { timestamp: number; platform: 'ios' | 'android' | 'web'; cpu: CpuInfo; memory: MemoryInfo; storage: StorageInfo; gpu?: GpuInfo; thermalState?: ThermalState; lowPowerMode?: boolean; sensors?: OnboardSensorsInfo;}OnboardSensorsInfo
온보드 센서 정보export interface OnboardSensorsInfo { availableSensors?: OnboardSensorDescriptor[]; readings?: OnboardSensorReading[]; batteryTemperatureCelsius?: number; ambientTemperatureCelsius?: number; relativeHumidityPercent?: number; pressureHpa?: number; illuminanceLux?: number; proximityDistanceCm?: number;}MonitoringOptions
모니터링 옵션export interface MonitoringOptions { intervalMs?: number; durationMs?: number; sampleCount?: number; emitImmediately?: boolean;}실제 데이터
실제 데이터 섹션이 페이지는 플러그인의 src/definitions.ts. upstream에서 변경된 경우 pubilc API를 다시 동기화하세요.
Getting Started에서 계속
Getting Started에서 계속이러한 장치 진단을 위해 Getting Started 장치 정보를 연결하세요. @capgo/capacitor-device-info 개요를 위해 Using @capgo/capacitor-device-info 튜토리얼을 위해 @capgo/capacitor-barometer 집중된 압력 측정값을 위해 @capgo/capacitor-light-sensor 집중된 조도 센서 측정값을 위해