Unable to use "Flashilight" plugin

Hi All, I want to turn flashlight on automatically (if possible) or manually (on and off) when starting scanning barcode. But I am even unable to just use the “Flashlight” plugin in ionic4, It is showing the “Object(…) is not a function” when calling any of the flashlight function such as this.flashlight.switchOn( ) etc. Error screenshot can be shown below:

00%20PM

anybody can pls help…

1 Like

Can you show the code that uses the flashlight?
It will be easier to see the issue seeing the code, rather then the resulting error message

@MattE here is the code:

AppModule.ts:

import { Flashlight } from ‘@ionic-native/flashlight/ngx’;
providers: [Flashlight]

CreateListing.ts:

import { Flashlight } from ‘@ionic-native/flashlight/ngx’;

class CreateListingPage {
constructor (private flashlight: Flashlight) {
}

      turnOnFlash() {
             this.flashlight.available(); // throws error as show in the question
             this.flashlight.switchOn(); // throws the same error
   
             // in same way, whatever function I am calling on this.flashlight instance throwing error
      }

}

I am having the same issue here. My code looks just like yours @pantarmj. Does anybody know how to fix it?

constructor(private barcodeScanner: BarcodeScanner,) {

}

anotherFunction() {  // call this function to start scanning the barcode
    this.barcodeScanner.scan({
            showTorchButton: true,
            torchOn: false,  // turns the torch on
            orientation: "orientation",
        }).then(
            (barcodeData) => { 
       console.log('Decoded data = ', barcodeData);
    }
}