wujek wujek - 1 year ago 93
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());

Answer Source

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);