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-light-sensor`
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/light-sensor/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.
インストール
「インストール」のセクションbun add @capgo/capacitor-light-sensorbunx cap syncインポート
「インポート」のセクションimport { LightSensor } from '@capgo/capacitor-light-sensor';APIの概要
「API オーバービュー」isAvailable
「isAvailable」現在のデバイスで光センサが利用可能かどうかを確認してください。 センサを使用する前に常にセンサの利用可能性を確認してください。
import { LightSensor } from '@capgo/capacitor-light-sensor';
const { available } = await LightSensor.isAvailable();start
「start」光センサの更新を聴き始める。
この機能は、指定された間隔でセンサ測定を開始します。
addListener を使用して、センサデータを受信します。
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.start({ updateInterval: 500 });stop
「stop」光センサの更新を聴き終わる。 この機能は、センサを停止し、バッテリーを節約します。
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.stop();checkPermissions
「checkPermissions」高サンプリングレートセンサーの現在の許可状態を確認してください。 Android 12+では、200ms未満のセンサーの更新間隔に対してHIGH_SAMPLING_RATE_SENSORS許可が必要です。
import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.checkPermissions();requestPermissions
「requestPermissions」セクション高サンプリングレートセンサーの許可を求めます。 Android 12+では、このHIGH_SAMPLING_RATE_SENSORS許可を要求します。
import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.requestPermissions();型の参照
「型の参照」セクションIsAvailableResult
「IsAvailableResult」セクションセンサが利用可能であることを示す結果。
export interface IsAvailableResult { /** * Whether the light sensor is available on this device. * Always false on iOS as the light sensor API is not available. * * @since 0.0.1 */ available: boolean;}StartOptions
「StartOptions」セクション光センサーリスナーの開始オプション
export interface StartOptions { /** * The desired interval between sensor updates in milliseconds. * On Android 12+, there's a minimum interval of 200ms unless the app * has the HIGH_SAMPLING_RATE_SENSORS permission. * * @default 200 * @since 0.0.1 */ updateInterval?: number;}LightSensorCallback
「光センサーのコールバック」セクション光センサーの更新に伴うコールバック関数。
export type LightSensorCallback = (measurement: LightSensorMeasurement) => void;PermissionStatus
「許可状態」セクション許可の要求またはチェックの結果。
export interface PermissionStatus { /** * Whether the high sampling rate sensor permission is granted. * On Android 12+, this permission is required for update intervals below 200ms. * * @since 0.0.1 */ highSamplingRate: 'prompt' | 'prompt-with-rationale' | 'granted' | 'denied';}VersionResult
「バージョン結果」セクションプラグインのバージョン情報。
export interface VersionResult { /** * The current version of the plugin. * * @since 0.0.1 */ version: string;}LightSensorMeasurement
「光センサーの測定値」セクション単一の光センサーの測定値。
export interface LightSensorMeasurement { /** * Ambient light level in lux (lx). * * @since 0.0.1 */ illuminance: number;
/** * Timestamp of the measurement in seconds since epoch. * * @since 0.0.1 */ timestamp: number;}真実の源
「真実の源」というセクションこのページはプラグインの src/definitions.ts公開 API がアップストリームで変更された場合に再度同期を実行してください。
「はじめから始める」から続けて
「はじめから始める」を使用計画用ダッシュボードと __CAPGO_KEEP_0__ の操作を実行する場合に接続してください。 「@__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-light-sensor」を使用 「@API/__CAPGO_KEEP_1__-light-sensor」を使用 「@capgo/capacitor-light-sensor」のネイティブ機能 「@capgo/capacitor-light-sensor」のネイティブ機能 API 圣四给 for the implementation detail in API 圣四给, 介绍 for the implementation detail in 介绍, API 筺给 for the implementation detail in API 筺给, 和 设备 for the implementation detail in 设备.