시작하기
이 플러그인 설치 단계와 전체 마크다운 가이드를 복사하세요.
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 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-sensorbunx cap syncImport
__CAPGO_KEEP_0__ 개요import { LightSensor } from '@capgo/capacitor-light-sensor';API 개요
APICopy to clipboard
import { LightSensor } from '@capgo/capacitor-light-sensor';
const { available } = await LightSensor.isAvailable();start
시작빛 센서 업데이트에 대한 청취를 시작하세요.
지정된 간격에서 센서 측정 시작합니다.
addListener 받기
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.start({ updateInterval: 500 });권한 상태를 확인하세요. 안드로이드 12 이상에서 HIGH_SAMPLING_RATE_SENSORS 권한이 필요합니다. 200ms 이하의 센서 업데이트 간격을 사용할 때
import { LightSensor } from '@capgo/capacitor-light-sensor';
await LightSensor.stop();checkPermissions
권한을 요청하세요.requestPermissions
import { LightSensor } from '@capgo/capacitor-light-sensor';
const status = await LightSensor.checkPermissions();requestPermissions
checkPermissions고속 센서 샘플링 요청 권한을 얻으십시오. 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
IsAvailableResult시작 옵션
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광 센서 업데이트 콜백 함수
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';}VersionResult
버전 결과조명 센서 측정
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;}LightSensorMeasurement
Source Of Truth이 페이지는 플러그인의 src/definitions.ts. 업스트림에서 API이 변경되었을 때 다시 싱크를 실행하세요.
Getting Started에서 계속
Getting Started에서 계속하는 섹션Getting Started을 사용하여 대시보드와 __CAPGO_KEEP_0__를 계획하고 운영하고 싶다면 Using @API/__CAPGO_KEEP_1__-light-sensor Using @capgo/capacitor-light-sensor를 사용하여 native 기능을 사용하는 @capgo/capacitor-light-sensor에 대한 기본 설정 API Overview를 사용하여 API Introduction 소개에서 구현 세부 정보를 위해 API 키 소개에서 API 키, 그리고 장치 소개에서 구현 세부 정보를 위해 장치.