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 Capacitor 8 버전 이상이 필요합니다 (@capacitor/core >=8.0.0).
You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:
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
Importimport { 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 델타 기반입니다. 첫 번째 네이티브 샘플은 생략할 수 있습니다; 호출하세요. getInfo() __CAPGO_KEEP_0__ 후에 다시 또는 사용 중인 CPU 사용률을 받기 위해 모니터링을 사용하세요.
__CAPGO_KEEP_0__ 업데이트
__CAPGO_KEEP_1__ 업데이트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);__CAPGO_KEEP_0__ 모니터링 동작
__CAPGO_KEEP_1__ 모니터링 동작intervalMs__CAPGO_KEEP_0__1000__CAPGO_KEEP_1__ 밀리초. __CAPGO_KEEP_0__ 밀리초 이하의 값은 __CAPGO_KEEP_1__ 밀리초로 클램핑됩니다.250__CAPGO_KEEP_0__250.emitImmediately__CAPGO_KEEP_1__true.- __CAPGO_KEEP_2__
durationMs__CAPGO_KEEP_2__sampleCount자동 모니터링을 중지합니다. - Calling
startMonitoring()활성화된 모니터링을 재시작하면 새로운 옵션으로 세션을 다시 시작합니다. - 모든
deviceInfoUpdate1부터 시작하는sequence, 세션의startedAt타임스탬프, 및elapsedMs.
업데이트를 중지하고 리스너를 제거합니다.
Section titled “업데이트를 중지하고 리스너를 제거합니다.”await DeviceInfo.stopMonitoring();await handle.remove();
// Or remove every listener registered on this plugin:await DeviceInfo.removeAllListeners();모니터링 상태를 확인
Section titled “모니터링 상태를 확인”const state = await DeviceInfo.isMonitoring();
if (state.monitoring) { console.log(state.samplesEmitted);}센서 field onboard
‘센서 field onboard’ 제목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__는 선택적입니다. 기기, OS, 앱 sandbox가 노출하는 메트릭이 있으면만 존재합니다.
플랫폼 참고사항
‘플랫폼 참고사항’ 제목- iOS는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CoreMotion 센서 가용성만 보고 raw CPU 또는 GPU 온도는 보고하지 않습니다.
- Android는 노출된 메트릭에 대한 권한이 필요하지 않습니다. CPU 및 GPU 온도는 최선의 노력으로 열 영역 읽기를 수행합니다.
- 웹 지원은 최선의 노력으로 클립보드 복사하고 빈 onboard 센서 배열을 보고합니다. 브라우저가 원시 기기 센서를 일관되게 노출하지 않기 때문입니다.
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 types
Section titled “Snapshot types”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 은 헤르츠이며, 온도 값들은 섭씨입니다. usagePercent 될 수 있습니다. null 플랫폼이 샘플을 계산할 수 있을 때까지.
Sensor types
Section titled “Sensor types”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 에포크 밀리초입니다. 일반적인 단위는 섭씨, 백분율, hPa, 라이트, 그리고 센티미터입니다.
Monitoring types
모니터링 유형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변경되면 이 페이지를 업데이트하세요.
시작부터 계속
시작부터 계속만약 __CAPGO_KEEP_0__을 사용 중이라면 Getting Started __CAPGO_KEEP_1__ 장치의 디버깅을 위해 장치를 연결하세요. capgo/capacitor-device-info __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-device-info를 사용하여 장치 정보를 확인하세요. capgo/capacitor-device-info를 사용하여 튜토리얼 페이지를 확인하세요. __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-barometer capgo/capacitor-barometer를 사용하여 집중된 압력 측정치를 확인하세요. __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-light-sensor capgo/capacitor-light-sensor를 사용하여 집중된 조도 센서 측정치를 확인하세요. __CAPGO_KEEP_0__/__CAPGO_KEEP_1__-light-sensor를 사용하여 조도 센서 측정치를 확인하세요.