[英]Phonegap plugin barcodescanner crashes on iOs
对于我正在从事的项目,必须有一种扫描QR码的方法。 我已经从phonegap-plugin-barcodescanner获得了这个。 照原样,它在Android上运行良好,从来没有任何问题。
但是在iOs上,它会崩溃。 您将收到使用相机的请求,然后该应用程序崩溃。 我找到的解决方法是删除其中的选项部分,然后工作。
这似乎是解决问题的一种奇怪方法。 问题:是否有更好的方法来解决此问题?
cordova.plugins.barcodeScanner.scan(
function (result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
},
function (error) {
alert("Scanning failed: " + error);
},
{
"preferFrontCamera" : true, // iOS and Android
"showFlipCameraButton" : true, // iOS and Android
"prompt" : "Place a barcode inside the scan area", // supported on Android only
"formats" : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
"orientation" : "landscape" // Android only (portrait|landscape), default unset so it rotates with the device
}
);
使用:Windows 10,Intel XDK v3619,Cordova CLI 6.2.0和phonegap-plugin-barcodescanner 4.1.0
我还通过Phonegap Build在IOS 10上的cordova-plugin-barcodescanner遇到了崩溃问题。
经过数小时的尝试现在解决了,我必须先添加cordova-plugin-camera ,然后再添加cordova-plugin-barcodescanner 。
这是我的工作config.xml的相关摘录:
<meta http-equiv="Content-Security-Policy" content="default-src * gap: file:; style-src 'self' 'unsafe-inline'; img-src 'self' data: gap:; script-src * 'unsafe-inline' 'unsafe-eval'"> <plugin name="cordova-plugin-camera" spec="~2.3.1"> <variable name="CAMERA_USAGE_DESCRIPTION" value="My App would like to access your camera, to take photos of your documents." /> </plugin> <preference name="android-build-tool" value="gradle" /> <plugin name="cordova-plugin-barcodescanner"> <variable name="CAMERA_USAGE_DESCRIPTION" value="abc123" /> </plugin>
在Android6和IOS10上,GitHub的示例现在都运行良好: https : //github.com/phonegap/phonegap-plugin-barcodescanner
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.