https://www.npmjs.com/package/@capacitor-community/barcode-scanner/v/5.0.0-beta.1
i am using ionic angular(i know this is just an angular discord server)
here is the code:
import { BarcodeScanner } from "@capacitor-community/barcode-scanner";
ngOnInit() {
this.startScanning()
}
async checkPermission() {
return new Promise(async (resolve, reject) => {
const status = await BarcodeScanner.checkPermission({force: true})
if (status.granted) {
resolve(true)
} else if(status.denied) {
BarcodeScanner.openAppSettings();
resolve(false)
}
})
}
async startScanning() {
const isAllowed = await this.checkPermission()
if (isAllowed) {
BarcodeScanner.hideBackground();
const result = await BarcodeScanner.startScan()
if(result.hasContent) {
this.scannedValue = result.content
console.log(this.scannedValue)
BarcodeScanner.stopScan()
} else {
console.error('No content found')
}
}
}
nothing is being console logged
npm
A fast and efficient (QR) barcode scanner for Capacitor. Latest version: 4.0.1, last published: 2 years ago. Start using @capacitor-community/barcode-scanner in your project by running npm i @capacitor-community/barcode-scanner. There are 7 other projects in the npm registry using @capacitor-community/barcode-scanner.