Install @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-light-sensor and start using its current __CAPGO_KEEP_2__ __CAPGO_KEEP_3__. - __CAPGO_KEEP_4__のアップデートをリアルタイムで管理して、ストアの手間を省きます。

ページ/エリア: Capgo マーケティング ウェブサイト。役割: ウェブサイト コピーの文。見つかった場所: component doc/SignupCta.astro、component Hero.astro。

GitHub

AIアシストセットアップを使用してプラグインをインストールできます。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.

もし、手動設定を希望する場合、以下のコマンドを実行し、下記のプラットフォーム固有の指示に従ってください。

ターミナル
bun add @capgo/capacitor-light-sensor
bunx cap sync
import { LightSensor } from '@capgo/capacitor-light-sensor';

APIの概要

API

コピー

import { LightSensor } from '@capgo/capacitor-light-sensor';
const { available } = await LightSensor.isAvailable();

光センサーの更新を開始します。 指定された間隔でセンサーの測定を開始します。 addListener を使用してセンサーデータを受信します。

import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.start({ updateInterval: 500 });

光センサーの更新を停止します。 センサーを停止し、バッテリーを節約します。

import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.stop();

高サンプリングレートセンサーの現在の許可状態を確認します。 Android 12+では、HIGH_SAMPLING_RATE_SENSORS許可が必要です センサーの更新間隔が200ms未満の場合。

import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.checkPermissions();

高サンプリングレートセンサーの許可を求めます。 Android 12+では、HIGH_SAMPLING_RATE_SENSORS許可を要求します。

import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.requestPermissions();

コピー

型参照

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;
}

センサが利用可能であることを示す結果。

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

「StartOptions」

光センサリスナーの開始オプション

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';
}

光センサーの測定

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;
}

PermissionStatus

VersionResult

このページはプラグインから生成されます。 src/definitions.ts.再度、上流のパブリック API が変更されたときに、再度同期を実行してください。

Getting Started から続けてください。

Section titled “Getting Started から続けてください”。

あなたが使用している場合 Getting Started ダッシュボードと API の計画と実行を計画するために使用している場合、API を接続してください。 @capgo/capacitor-light-sensorを使用します。 Using @capgo/capacitor-light-sensor のネイティブ機能のために API API Overview の実装詳細のために Introduction 導入の詳細については、導入のページを参照してください。 API キー for API の実装詳細について Devices for the implementation detail in __CAPGO_KEEP_1__.