메뉴로 바로가기

Getting Started

터미널 창
bun add @capgo/capacitor-light-sensor
bunx cap sync
import { LightSensor } from '@capgo/capacitor-light-sensor';

__CAPGO_KEEP_2__ 현재 장치에서 빛 센서가 사용 가능합니까? 센서 사용을 시도하기 전에 항상 센서 사용 가능 여부를 확인하세요.

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

클립보드 복사

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

requestPermissions

클립보드 복사

__CAPGO_KEEP_0__의 고속 센서에 대한 권한 요청. Android 12+에서 이 요청은 HIGH_SAMPLING_RATE_SENSORS 권한을 요청합니다.

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

__CAPGO_KEEP_0__을 클립보드에 복사

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

__CAPGO_KEEP_0__을 클립보드에 복사

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

__CAPGO_KEEP_0__을 클립보드에 복사

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

PermissionStatus

__CAPGO_KEEP_1__

__CAPGO_KEEP_2__

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_1__

__CAPGO_KEEP_3__

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

LightSensorMeasurement

__CAPGO_KEEP_1__

__CAPGO_KEEP_4__

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_1__

__CAPGO_KEEP_5__

This page is generated from the plugin’s src/definitions.ts업스트림에서 pubic API이 변경될 때 다시 싱크를 실행하세요.

Getting Started에서 계속하세요.

Getting Started에서 계속하세요.

Getting Started를 사용하여 대시보드와 __CAPGO_KEEP_0__ 연산을 계획하고 있다면, @__CAPGO_KEEP_0__/__CAPGO_KEEP_1__-light-sensor를 사용하여 @API/__CAPGO_KEEP_1__-light-sensor를 사용하여 native capability를 구현하세요. Using @capgo/capacitor-light-sensor for the native capability in Using @capgo/capacitor-light-sensor, API Overview for the implementation detail in API Overview, 소개 __CAPGO_KEEP_0__ 구현 세부 사항에 대해 API 키 API 키의 구현 세부 사항에 대해, 및 기기 기기 구현 세부 사항에 대해.