Unable to use "Flashilight" plugin


#1

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:

anybody can pls help…


#2

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


#3

@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
      }

}