Notice: The Monaca & Onsen UI Community Forum is shutting down.

For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.

Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.

We need a Flashlight toggle switches when barcode scanner on

  • Hi all,

    I am developing a Monaca app which uses a barcode scanner plugin to scan. I used for implementing barcode scanner and it works fine.

    I implemented the flashlight plugin with

    The functionality that I need to implement is, the flashlight of the mobile should automatically switch on when the scanning starts and should automatically switch off once the scan is complete.

    I tried the following code:

    <img class="mrg-bt" src="img/qr-scanner.png" onclick="scan();">
    function scan(){
      scanlight(true); //switch on flashlight
            //scan success code
             scanlight(false);//switch off flashlight
    //flashlight function call
    function scanlight(enable) {
    window.plugins.flashlight.available(function (isAvailable) {
       if (isAvailable) {
          if (enable) {
                function () { },
                 function () { },  
                 { intensity: 0.3}   
          } else {

    The issue is, the functionality is happening quite opposite to my requirement. When I hit the scan button the flashlight gets on and after the camera opens the flashlight goes off and the flashlight gets on once the camera is closed.

    Someone please help me to get rid of this. Thanks in advance.

  • @Amirtha I believe this is due to the camera wanting the flashlight for its flash functionality. I did find this on SO though: