wujek wujek - 1 month ago 11x
AngularJS Question

can't get brightness ionic cordova-plugin-brightness

I have problem with get brightness from cordova-plugin-brightness.
I get undefind object. (I can set brightness but I can't get brightness)

var LightControl = cordova.plugins.brightness;

console.log("brightness: "+LightControl.getBrightness());


According to the documentation of this plugin, you need to pass functions as parameters to the getBrightness() function.

So in that case, your code would look something like this:

var LightControl = cordova.plugins.brightness;

LightControl.getBrightness(function(brightness) {
  console.log("The current brightness is: " + brightness);
}, function(error) {
  console.log("Error: " + error);