Skip to content

はじめから始める

GitHub

AI-Assisted Setupを使用してプラグインをインストールできます。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-sensor
bunx cap sync
import { LightSensor } from '@capgo/capacitor-light-sensor';

「API オーバービュー」のセクション

Section titled “API Overview”

isAvailable

protectedTokens

デバイス上の光センサーが利用可能であるかどうかを確認してください。 常にセンサーの利用可能性を確認する必要があります。

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+ では、センサー更新間隔が 200ms 未満の場合、HIGH_SAMPLING_RATE_SENSORS 許可が必要です。

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();

センサが利用可能であるかどうかの結果を示します。

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

光センサーの更新のためのコールバック関数。

export type LightSensorCallback = (measurement: LightSensorMeasurement) => void;

許可の要求または確認の結果。

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

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リランするsyncをpublic APIがアップストリームで変更されたときに。

「Getting Started」から続けて

「Getting Started」から続けて

「Getting Started」を使用している場合 「Getting Started」 「Getting Started」を使用してダッシュボードとAPIの作業を計画する場合、APIを 「@capgo/capacitor-light-sensor」 「@capgo/capacitor-light-sensor」で使用するネイティブ機能のために「@capgo/capacitor-light-sensor」 「API」 「API」の実装詳細のために「API」 導入 導入の実装詳細のために API キー API キーの実装詳細のために、 デバイス デバイスの実装詳細のために