시작하기
이 플러그인의 설치 단계와 전체 마크다운 가이드를 포함한 설정 명령어를 복사하세요.
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 sync수입
Importimport { DeviceInfo } from '@capgo/capacitor-device-info';한 번의 스냅샷 읽기
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 delta 기반입니다. 첫 번째 네이티브 샘플에서는 생략할 수 있습니다; 호출 getInfo() 스트림 업데이트
Section titled “Stream updates”
모니터링 동작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);Section titled “Monitoring behavior”
protectedTokensintervalMs기본값으로1000밀리초. 값이 아래250밀리초는 클램핑됩니다.250.emitImmediately기본값으로true.- 설정
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 온도는 최선의 노력으로 열 영역의 읽기입니다.
- 웹 지원은 최선의 노력으로 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() 개별 리스너를 제거하는 방법을 설명합니다.
스냅샷 유형
스냅샷 유형 섹션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 플랫폼이 샘플을 계산할 수 있을 때까지 기다립니다.
센서 종류
‘센서 종류’ 제목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, 라이트, 센티미터입니다.
모니터링 종류
‘모니터링 종류’ 제목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 각 모니터링 세션에서 시작됩니다.
실제 데이터의 출처
‘실제 데이터의 출처’라는 제목이 참조는 플러그인의 공공 API을 따릅니다. src/definitions.ts공개 __CAPGO_KEEP_0__을 따릅니다.
이 페이지를 업데이트할 때마다 그 출처가 변경되면.
Getting Started에서 계속‘Getting Started에서 계속’이라는 제목 이 플러그인을 사용하는 경우 Getting Started @capgo/capacitor-장치 정보 Getting Started Capgo 사용자 가이드: @capgo/capacitor-device-info 튜토리얼 페이지를 위해 @capgo/capacitor-barometer 집중된 압력 읽기와 @capgo/capacitor-light-sensor 집중된 조도 센서 읽기