代码之家  ›  专栏  ›  技术社区  ›  RubbelDieKatz

ios12safari:有没有办法让基于web的QR扫描正常工作?

  •  0
  • RubbelDieKatz  · 技术社区  · 6 年前

    有一些基于网络的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.");
    }
    
    1 回复  |  直到 6 年前
        1
  •  2
  •   RubbelDieKatz    6 年前

    extensive conversation 与开发商 JsQRScanner ,我们可以在Safari上进行QR扫描。