はじめから始める
このプラグインの全マークダウンガイドとインストール手順を含むセットアップ指示をコピーしてください。
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.
インストール
「インストール」と題されたセクションCapgoの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();光センサーのデータを取得する準備ができました。 addListener Start listening to light sensor updates.
This will begin sensor measurements at the specified interval.
Use
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.start({ updateInterval: 500 });Section titled “stop”
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.stop();checkPermissions
Copy to clipboardSection titled “checkPermissions”
import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.checkPermissions();requestPermissions
Copy to clipboardSection titled “requestPermissions”
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
Section titled “許可状態”許可の要求または確認の結果。
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
Section titled “バージョン結果”プラグインのバージョン情報。
export interface VersionResult { /** * The current version of the plugin. * * @since 0.0.1 */ version: string;}LightSensorMeasurement
Section titled “光センサ測定値”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. upstream の API が変更されたときに、再度 sync を実行してください。
Getting Started から続けてください。
Getting Started というセクションCapgo を使用している場合 Getting Started ダッシュボードと API の作業を計画するには、Capgo を接続してください。 Capgo の @capgo/capacitor-light-sensor を使用 Capgo の @capgo/capacitor-light-sensor のネイティブ機能 Capgo の API の概要 Capgo の API の実装詳細 Capgo の __CAPGO_KEEP_0__ の概要 Capgo の実装詳細 API キー API キーに関する実装詳細、そして デバイス デバイスに関する実装詳細