I want to use BarCodeScanner in Ionic 6 but when I call the function to open the camera and scan, I get the message Scan is already in progress. It doesn't open the camera or do anything. I don't understand why this is happening, if someone could help me, I would be very grateful. Attached is my code:
import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
constructor(
private menuCtrl:MenuController,
private apiService: ApiService,
private modalCtrl: ModalController,
private barcodeScanner: BarcodeScanner
) { }
public scan(){
this.barcodeScanner.scan().then(barcodeData => {
console.log('Barcode data', barcodeData);
this.scannedData = barcodeData;
}).catch(err => {
console.log('Error', err);
});
}
And app.module.ts:
import { BarcodeScanner } from '@ionic-native/barcode-scanner/ngx';
providers: [
{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy },
Stripe,
Camera,
BarcodeScanner,
StatusBar,
SplashScreen
],