Skip to content

@capgo/capacitor-light-sensor

Capacitor plugin for accessing the device's ambient light sensor.

Capacitor plugin for accessing the device’s ambient light sensor.

  • 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.
  • 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.
MethodDescription
isAvailableCheck if the light sensor is available on the current device. You should always check sensor availability before attempting to use it.
startStart listening to light sensor updates. This will begin sensor measurements at the specified interval. Use addListener to receive the sensor data.
stopStop listening to light sensor updates. This will stop the sensor and conserve battery.
addListenerAdd a listener for light sensor change events. The listener will be called whenever new sensor data is available.
removeAllListenersRemove all listeners for light sensor events.
checkPermissionsCheck 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.
requestPermissionsRequest permission for high sampling rate sensors. On Android 12+, this requests the HIGH_SAMPLING_RATE_SENSORS permission.
getPluginVersionGet the current version of the plugin.

This reference is synced from src/definitions.ts in capacitor-light-sensor.