IOS12 Safari:有没有办法使基于Web的QR扫描工作?

问题描述 投票:0回答:2
那里有一些基于Web的QR扫描仪的示例,尤其是

Instascanrepo)和jsqrscannerrepo)。这两者都在Android上完美无缺。但是,在iPhone上使用iOS 12的Safari上,示例和我的代码都会令人震惊,从而产生了一个黑匣子,视频提要应该或根本没有。如果我无法访问Promise对象,我将无法抓住JavaScript承诺,我无法在没有Mac的情况下进行调试。 我尝试了这两个库

我什至与其中一个开发人员进行了交流,但日志可以简化过程。如果没有适当的工具,我无法在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."); }

与JSQRSCANNER的开发人员进行扩展的对话
,我们能够在Safari上进行QR扫描工作。
    
javascript ios safari promise mobile-safari
2个回答
6
投票
问题中描述的黑匣子表明,此问题的答案解决了此问题:

在iPhone上iOS Safari中的相机访问 所提出的修复是将其添加到视频元素中:

// Fix for iOS Safari from https://leemartin.dev/hello-webrtc-on-safari-11-e8bcb5335295 video.setAttribute('autoplay', ''); video.setAttribute('muted', ''); video.setAttribute('playsinline', '');

1
投票

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.