Skip to content

@capgo/capacitor-light-sensor

Access the ambient light sensor to measure illuminance levels in lux with real-time updates

Access the ambient light sensor to measure illuminance levels in lux with real-time updates

Start with isAvailable() and the other core methods listed below.

PlatformSupportNotes
iOSYesNative
AndroidYesNative
WebNoGuard with Capacitor.getPlatform()
  • 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.

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.