컨텐츠로 바로가기

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.

설치 및 동기화, 그리고 소스 마크다운 설명서가 포함됩니다.

Terminal window
bun add @capgo/capacitor-light-sensor
bunx cap sync
import { LightSensor } from '@capgo/capacitor-light-sensor';

isAvailable

__CAPGO_KEEP_2__

__CAPGO_KEEP_3__ 센서가 현재 장치에 사용 가능한지 확인하세요. 센서 사용을 시도하기 전에 항상 센서 사용 가능 여부를 확인하세요.

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

__CAPGO_KEEP_1__ 센서 업데이트에 대한 청취를 시작하세요. 지정된 간격에서 센서 측정 시작합니다. 사용 addListener __CAPGO_KEEP_0__를 받기 위해.

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

__CAPGO_KEEP_0__를 중지하여 배터리 소모를 줄입니다. 센서를 중지하고 배터리를 절약합니다.

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

checkPermissions

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__의 현재 권한 상태를 확인합니다. Android 12+에서 HIGH_SAMPLING_RATE_SENSORS 권한이 필요합니다. 센서 업데이트 간격이 200ms 이하일 때.

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

requestPermissions

__CAPGO_KEEP_0__

__CAPGO_KEEP_0__를 요청합니다. Android 12+에서 HIGH_SAMPLING_RATE_SENSORS 권한을 요청합니다.

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

__CAPGO_KEEP_0__

Type Reference

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

StartOptions

광 센서 리스너를 시작하는 데 필요한 옵션.

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

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

광선 센서 측정 섹션

광선 센서 측정 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. Re-run the sync when the public API changes upstream.

Getting Started에서 계속 진행하세요

Getting Started에서 계속하기

__CAPGO_KEEP_0__을 사용하는 경우 Getting Started API과 API 연동을 위해 @capgo/capacitor-light-sensor를 사용하세요. @capgo/capacitor-light-sensor의 Native Capability을 위해 API 개요 API 개요의 구현 세부 정보를 위해 소개 소개의 구현 세부 정보를 위해 API 키 API 키의 구현 세부 정보를 위해 __CAPGO_KEEP_0__ __CAPGO_KEEP_1__