Phonegap:无法使用Barcode Scanner插件

时间:2016-01-24 18:31:39

标签: ios cordova phonegap-plugins barcode-scanner

我正在尝试使用Phonegap创建条形码扫描仪应用程序。我正在使用Phonegap Developer应用程序在iPhone 6s上进行测试。

当我点击扫描按钮时,根本没有任何事情发生。

除了编辑index.html文件并使用Phonegap桌面应用程序作为服务器之外,我还需要采取其他步骤吗?

这是我的第一个混合应用程序。我的目标平台和版本是iOS 9。

我只是在手机上使用PhoneGap桌面应用程序和PhoneGap开发应用程序。我需要采取另一个步骤(构建等吗?)这是为什么它不起作用?

这是我的index.html页面(从这里复制,作为工作示例给出):

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
</head>
<body>

<button onclick="scanBarcode()">Scan</button>

    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script>
    function scanBarcode(){

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);
  }
 );
}

    </script>

</body>
</html>

0 个答案:

没有答案