【问题标题】:iOS 12 Safari: Is there a way to make web-based QR Scanning work?iOS 12 Safari:有没有办法让基于 Web 的 QR 扫描工作?
【发布时间】:2018-09-20 12:27:06
【问题描述】:

有一些基于 Web 的 QR 扫描仪的工作示例,特别是 Instascan (repo) 和 JsQRScanner (repo)。这两种方法都可以在 Android 上完美运行。然而,在 iPhone 上带有 iOS 12 的 Safari 上,示例和我的代码都严重失败,产生了一个黑匣子,视频源应该是或根本没有。如果没有 mac,我无法调试它,因为如果我无法访问 Promise 对象,我将无法捕获 javascript Promise。

我尝试了这两个库and I even communicated with one of the developers,但日志会简化这个过程。如果没有 Safari 上的适当工具,我无法生成这些日志。

有什么方法可以让 Safari 正常工作吗?

这是我的 JsQRScanner 代码的一部分。我还保留了旧的 InstaScan 代码,以防有人需要。

/**
 * 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.");
}

【问题讨论】:

标签: javascript ios safari promise mobile-safari


【解决方案1】:

在与JsQRScanner 的开发者交流extensive conversation 之后,我们能够在 Safari 上进行 QR 扫描。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-02
    相关资源
    最近更新 更多