Я хочу использовать QrScanner в своем приложении. Итак, я установил
ionic cordova plugin add cordova-plugin-qrscanner
npm install --save @ionic-native/qr-scanner@beta
плагины, затем я запускаю браузер ionic cordova, затем я получаю доступ к созданной ссылке на моем мобильном телефоне. Когда я пытаюсь открыть сканер qr, он всегда показывает camera is not available
. Несмотря на то, что у моего мобильного есть камера, я тестировал как на Android, так и на IOS, но результаты одинаковы. Вот мой код
this.qrScanner.prepare()
.then((status: QRScannerStatus) => {
if (status.authorized) {
// camera permission was granted
// start scanning
const scanSub = this.qrScanner.scan().subscribe((text: string) => {
console.log('Scanned something', text);
this.sharedAlertService.presentBasicAlert('Authorized', '', JSON.stringify(text));
this.qrScanner.hide(); // hide camera preview
scanSub.unsubscribe(); // stop scanning
});
} else if (status.denied) {
this.sharedAlertService.presentBasicAlert('Denied', '', 'No permission');
// camera permission was permanently denied
// you must use QRScanner.openSettings() method to guide the user to the settings page
// then they can grant the permission from there
} else {
// permission was denied, but not permanently. You can ask for permission again at a later time.
}
})
.catch((e: any) => this.sharedAlertService.presentBasicAlert('Error', '', JSON.stringify(e)));
Каково решение для доступа к сканеру qr в браузерах? Спасибо.