Skip to content

Getting Started

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

__CAPGO_KEEP_0__ 사용 가능한지 확인하세요. 센서 사용 전에 항상 사용 가능 여부를 확인하세요.

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

__CAPGO_KEEP_3__ 센서 업데이트 시작. 지정된 간격에서 센서 측정 시작. __CAPGO_KEEP_4__ 센서 데이터를 받기 위해 사용하세요. addListener __CAPGO_KEEP_1__ 복사

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

__CAPGO_KEEP_1__ 복사

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

__CAPGO_KEEP_1__ 복사

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

클립보드에 복사

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

광 센서 콜백

__CAPGO_KEEP_0__

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

PermissionStatus

__CAPGO_KEEP_2__

__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

__CAPGO_KEEP_2__

__CAPGO_KEEP_2__

export interface VersionResult {
/**
* The current version of the plugin.
*
* @since 0.0.1
*/
version: string;
}

LightSensorMeasurement

__CAPGO_KEEP_2__

__CAPGO_KEEP_2__

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

__CAPGO_KEEP_0__

Source Of Truth

이 페이지는 플러그인의 src/definitions.ts. 업스트림의 공공 API이 변경되었을 때 다시 싱크를 실행하세요.

Getting Started

Getting Started

이러한 기능을 사용 중이라면 Getting Started 계획 대시보드 및 API 작업을 위해 연결하세요. Using @capgo/capacitor-light-sensor Using @capgo/capacitor-light-sensor API Overview API Overview __CAPGO_KEEP_0__ Introduction API Keys API Keys Devices __CAPGO_KEEP_0__