@capgo/capacitor-device-info を使用
CPU、メモリ、GPU、ストレージ、熱管理、低消費電力、そしてオンボードセンサーのメトリックを Capacitor アプリから取得
互換性
このプラグインは Capacitor 8 またはそれ以降が必要@capacitor/core >=8.0.0).
インストール
npm install @capgo/capacitor-device-info
npx cap sync
このプラグインが公開するもの
getInfo- CPU、メモリ、GPU、ストレージ、熱管理状態、低消費電力モード、オンボードセンサーの 1 つのスナップショットを読み取るstartMonitoring- チャートや診断ダッシュボード用の周期的なスナップショットを開始するstopMonitoring- アクティブなストリームを停止するisMonitoring- ストリームのステータスと発行されたサンプル数を確認するremoveAllListeners- プラグインに登録されたすべてのリスナーを削除するdeviceInfoUpdate- __CAPGO_KEEP_0__イベントが周期的なサンプルごとに発生します。
例えば
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.gpu?.renderer);
console.log(snapshot.sensors?.pressureHpa);
チャートにメトリクスをストリームする
import { DeviceInfo } from '@capgo/capacitor-device-info';
const samples: number[] = [];
const handle = await DeviceInfo.addListener('deviceInfoUpdate', (sample) => {
if (typeof sample.cpu.usagePercent === 'number') {
samples.push(sample.cpu.usagePercent);
}
});
await DeviceInfo.startMonitoring({
intervalMs: 1000,
emitImmediately: true,
});
// Later:
await DeviceInfo.stopMonitoring();
await handle.remove();
監視はデフォルトで1000msの間隔に設定され、下限は250ms、即時サンプルも発生します。ただし、__CAPGO_KEEP_1__を設定しない限り emitImmediately: false再び呼び出すと、有効なセッションを再起動し、新しいオプションで再度呼び出します。各イベントには、__CAPGO_KEEP_2__、__CAPGO_KEEP_3__、__CAPGO_KEEP_4__が含まれます。 startMonitoring() を使用して自動停止することもできます。必要なくなったら、を呼び出してください。 sequence, startedAtセンサーノート elapsedMs.
センサーデータは任意のオプションです。デバイスは異なるハードウェアを公開します。Androidはバッテリー温度、環境温度、湿度、気圧、光、近接性、最善の努力でCPU/GPU熱ゾーン値を報告できます。iOSはCoreMotionセンサーの可用性、熱状態、低電力状態を報告しますが、パブリックiOSAPIはRAWのCPUまたはGPU温度を公開していません。 durationMs Sensor readings are optional because devices expose different hardware. sampleCount Android can report battery temperature, ambient temperature, humidity, barometric pressure, light, proximity, and best-effort CPU/GPU thermal-zone values when available. await DeviceInfo.removeAllListeners().
iOS reports CoreMotion sensor availability, thermal state, and low-power state, but public iOS APIs do not expose raw CPU or GPU temperature.
Monitoring defaults to a 1000 ms interval, clamps intervals below 250 ms, and emits an immediate sample unless you set
The plugin does not fetch weather data. Outside temperature and humidity require a separate location and weather API integration.
フルリファレンス
続ける
あなたが @capgo/capacitor-device-info 診断画面や監視画面を作る場合、__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-device-infoと接続してください。 @capgo/capacitor-device-info 概要の場合、 外部設定 for install and API examples、 Using @capgo/capacitor-barometer for dedicated pressure streaming、そして Using @capgo/capacitor-light-sensor for dedicated light readings。