i want to create a Qr code reader that is created on web, but i also want it to be compatible when it will be open on the browser of the mobile. i used instascan library it works fine on my computer but when it comes to my browser in mobile it doesn't seems to work or it is not compatible. can anyone help me please i really need it.
You most likely have this or this issue with instascan, are you possibly running android 7 or have a HTC device? Multiple people have reported issues with the instascan package with those devices. What you could try is NIMIC QR scanner
We used LazarSofts jsqrcode before.
On desktop users could just upload photo with qr-code, and they had option to directly take photo with mobile phone.
I know this is not the cleanest solution, but it worked for us.
HTML:
<input type=file accept="image/*" capture=environment id="qr-scanner" tabindex=-1>
JS
// open the scanner
$(document).on('change', '#qr-scanner', function (e) {
e.preventDefault();
e.stopPropagation();
var scanResult = scanQR(this);
});
// process the image with scanner
function scanQR(node) {
var reader = new FileReader();
reader.onload = function() {
qrcode.callback = function(res) {
if(res instanceof Error) {
handleScanResults(false);
} else {
handleScanResults(res);
}
};
qrcode.decode(reader.result);
};
reader.readAsDataURL(node.files[0]);
}
// handle scanner results
function handleScanResults(scanResult) {
if (scanResult) {
alert(scanResult);
} else {
alert('Scan error, try again.');
}
}
我推荐你使用Dynamsof Barcode Reader JavaScript 库:https://www.dynamsoft.com/Products/barcode-recognition-javascript.aspx。
可以先尝试一下这个已经建立好的demo
,可以在电脑网页端,安卓的chrome,firefox,ios的Safari等等主流浏览器上运行。