はじめから始める
このプラグインのインストール手順とフルマークダウンガイドを含むセットアッププロンプトをコピーします。
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.
インストール
「インストール」のセクションAI-Assisted セットアップを使用してプラグインをインストールできます。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-light-sensor` plugin in my project.Manual Setup を好む場合は、以下のコマンドを実行してプラグインをインストールし、下記のプラットフォーム固有の指示に従ってください:
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 「to」でセンサデータを受信します。
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
「LightSensorCallback」セクション__CAPGO_KEEP_0__
export type LightSensorCallback = (measurement: LightSensorMeasurement) => void;PermissionStatus
許可状態__CAPGO_KEEP_0__
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
光センサ測定光センサの1回の測定
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 がアップストリームで変更された場合、再度同期を実行してください。
Getting Started から続けて
Getting Started から続けてあなたが「 Getting Started ダッシュボードと API の作業を計画する場合、 Using @capgo/capacitor-light-sensor for the native capability in Using @capgo/capacitor-light-sensor, API Overview for the implementation detail in API Overview, 概要 概要の実装詳細については、 API キー API キーの実装詳細については、 デバイス デバイスの実装詳細については。