Change screen brightness - unable to access the cordova-plugin-brightness plugin object in ionic


#1

Hello,

I would like to adjust smartphone screen brightness using this plugin and I don’t know how to access the plugin at all in ionic/angular.

I already have experience with other cordova plugins, e.g., this code works properly for me to keep screen on and run the app fullscreen:

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    ionic.Platform.fullScreen()
    if (typeof(window.plugins) !== 'undefined') {
       window.plugins.insomnia.keepAwake() // keep display on
     }
  });
})

However there is no window.plugins.brightness defined even at android smartphone.

Thanks in advance for help.


#2

Hi!

It works pretty well for me with following this example : https://github.com/fiscal-cliff/phonegap-plugin-brightness.

Take care to call the window.brightness = cordova.require(“cordova.plugin.Brightness.Brightness”); in a $timeout function with a few delay (200ms in my case).

Regards,


#3

DFull, thank you for help.
the fiscal-cliff/phonegap-plugin-brightness works well.