컨텐츠로 바로가기

시작하기

GitHub

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.

Copy to clipboard

만들기(Manual Setup)로 선호하시면, 다음 명령어를 실행하고 아래의 플랫폼별 설명을 따라해 주세요.
bun add @capgo/capacitor-light-sensor
bunx cap sync

Copy to clipboard

Import
import { LightSensor } from '@capgo/capacitor-light-sensor';

API Overview

API 개요

"isAvailable" 섹션

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

고속 샘플링 센서에 대한 현재 권한 상태를 확인합니다. 안드로이드 12 이상에서 HIGH_SAMPLING_RATE_SENSORS 권한이 필요합니다. 200ms 이하의 센서 업데이트 간격을 위해.

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

고속 샘플링 센서에 대한 권한을 요청합니다. 안드로이드 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;
}

광 센서 업데이트 콜백 함수.

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

실질적 원천

실질적 원천

이 페이지는 플러그인의 소스 코드에서 생성됩니다. src/definitions.ts. upstream의 API이 변경될 때 다시 싱크를 실행하세요.

Getting Started에서 계속

Getting Started에서 계속하는 섹션

Capacitor를 사용하는 경우 Getting Started Capacitor를 사용하여 대시보드와 API를 계획하고 운영하기 위해 연결하세요. Capacitor를 사용하여 @capgo/capacitor-light-sensor Capacitor를 사용하여 @capgo/capacitor-light-sensor의 네이티브 기능 API 개요 API 개요의 구현 세부 정보 소개 소개의 구현 세부 정보 API 키 implementation 세부 정보에 대한 API 키 장치 implementation 세부 정보에 대한 장치