Rub*_*atz 5 javascript safari mobile-safari promise ios
有一些基于 Web 的 QR 扫描仪的工作示例,特别是Instascan ( repo ) 和JsQRScanner ( repo )。这两个功能在 Android 上都能完美运行。然而,在 iPhone 上运行 iOS 12 的 Safari 浏览器上,示例和我的代码都严重失败,产生了一个黑匣子,其中应该有视频源,或者什么也没有。如果没有 Mac,我无法调试它,因为如果我无法访问 Promise 对象,我就无法捕获 JavaScript Promise。
我尝试了这两个库,甚至与其中一位开发人员进行了沟通,但日志会简化该过程。如果没有适当的工具,我无法在 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.");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
16793 次 |
| 最近记录: |