Phonegap插件条形码扫描器在iOs上崩溃

时间:2016-10-26 07:58:12

标签: javascript android ios cordova intel-xdk

对于我正在研究的项目,必须有一种扫描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

1 个答案:

答案 0 :(得分:2)

我还通过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

相关问题