有一些基于网络的QR扫描仪的工作实例,特别是
Instascan
repo
)以及
JsQRScanner
repo
). 这两个都在Android上完美地工作。不过,在iPhone上安装ios12的Safari上,示例和代码都出现了可怕的失败,生成了一个视频提要应该在的黑盒,或者根本没有。如果没有mac,我就无法调试它,因为如果无法访问promise对象,我就无法捕获javascript承诺。
我两个图书馆都试过了
and I even communicated with one of the developers
有什么方法可以让事情在Safari上正常运行吗?
/**
* Sets up the QR scanner.
* this function will be called when JsQRScanner is ready to use
* @see https://github.com/jbialobr/JsQRScanner
*/
function JsQRScannerReady() {
try {
//create a new scanner passing to it a callback function that will be invoked when
//the scanner succesfully scan a QR code
var jbScanner = new JsQRScanner(scanEvent);
setResult("Constructed JsQRScanner object.");
//reduce the size of analyzed images to increase performance on mobile devices
jbScanner.setSnapImageMaxSize(300);
setResult("setSnapImageMaxSize completed.");
var scannerParentElement = document.getElementById("videoBoundingBox");
if (scannerParentElement) {
//append the jbScanner to an existing DOM element
jbScanner.appendTo(scannerParentElement);
setResult("Appended jbScanner to div.");
}
} catch (e) {
setResult("Caught exception in the camera initialisation.");
setResult(e.message);
}
setResult("initialisation complete.");
}