This plugin can be use to get intensity level that falls in to the device. The API supports to one time call and repeated calls which will directed to callback functions.
A successful response receive as a JSON, {"intensity":5}
The value that get from reading
object is in Lux (measurement unit)
cordova plugin add https://github.com/DeshanKTD/cordova-plugin-lightsensor
- window.plugin.lightsensor.getReading
- window.plugin.lightsensor.watchReadings
- window.plugin.lightsensor.stop
This method get a single reading from the lightsensor sensor
window.plugin.lightsensor.getReading(
function success(reading){
console.log(JSON.stringify(reading));
alert(JSON.stringify(reading));
// Output: {"intensity": 25}
},
function error(message){
console.log(message);
}
)
reading
object properties
intensity
This helps get reapeated readings from the lightsensor sensor.
window.plugin.lightsensor.watchReadings(
function success(reading){
console.log(JSON.stringify(reading));
alert(JSON.stringify(reading));
// Output: {"intensity": 25}
},
function error(message){
console.log(message);
}
)
reading
object properties
intensity
Stops getting readings from the lightsensor sensor.
window.plugin.lightsensor.stop([watchID])
- Android