@capgo/capacitor-light-sensor
Capacitor plugin for accessing the device's ambient light sensor.
Overview
Section titled “Overview”Capacitor plugin for accessing the device’s ambient light sensor.
Core Capabilities
Section titled “Core Capabilities”isAvailable- Check if the light sensor is available on the current device. You should always check sensor availability before attempting to use it.start- Start listening to light sensor updates. This will begin sensor measurements at the specified interval. UseaddListenerto receive the sensor data.stop- Stop listening to light sensor updates. This will stop the sensor and conserve battery.checkPermissions- Check the current permission status for high sampling rate sensors. On Android 12+, the HIGH_SAMPLING_RATE_SENSORS permission is required for sensor update intervals below 200ms.
Public API
Section titled “Public API”| Method | Description |
|---|---|
isAvailable | Check if the light sensor is available on the current device. You should always check sensor availability before attempting to use it. |
start | Start listening to light sensor updates. This will begin sensor measurements at the specified interval. Use addListener to receive the sensor data. |
stop | Stop listening to light sensor updates. This will stop the sensor and conserve battery. |
addListener | Add a listener for light sensor change events. The listener will be called whenever new sensor data is available. |
removeAllListeners | Remove all listeners for light sensor events. |
checkPermissions | Check the current permission status for high sampling rate sensors. On Android 12+, the HIGH_SAMPLING_RATE_SENSORS permission is required for sensor update intervals below 200ms. |
requestPermissions | Request permission for high sampling rate sensors. On Android 12+, this requests the HIGH_SAMPLING_RATE_SENSORS permission. |
getPluginVersion | Get the current version of the plugin. |
Source Of Truth
Section titled “Source Of Truth”This reference is synced from src/definitions.ts in capacitor-light-sensor.
Keep going from @capgo/capacitor-light-sensor
Section titled “Keep going from @capgo/capacitor-light-sensor”If you are using @capgo/capacitor-light-sensor to plan dashboard and API operations, connect it with Using @capgo/capacitor-light-sensor for the native capability in Using @capgo/capacitor-light-sensor, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, API Keys for the implementation detail in API Keys, and Devices for the implementation detail in Devices.