简体   繁体   English

使用Phonegap CLI-条形码扫描仪不起作用

[英]Using Phonegap CLI - Barcode scanner not working

I developing an app for iOS and Android using PhoneGap 3.4.0 from the command line interface, and want to make use of the BarcodeScanner plugin. 我从命令行界面使用PhoneGap 3.4.0开发了适用于iOS和Android的应用程序,并希望使用BarcodeScanner插件。 The problem is that the scanner does not actually do anything when called by my app. 问题在于,当我的应用程序调用扫描程序时,扫描仪实际上不执行任何操作。 The camera does not come up. 相机无法启动。 By using console.log with Safari developer tools, I can tell that the scan function does exist and is getting called... it just isn't doing anything. 通过将console.log与Safari开发人员工具一起使用,我可以知道扫描功能确实存在并且正在被调用……它什么都没做。

I installed the scanner plugin like this: phonegap plugin add https://github.com/wildabeast/BarcodeScanner 我这样安装了扫描仪插件: phonegap plugin add https://github.com/wildabeast/BarcodeScanner

In the index.html, included the javascripts like this: 在index.html中,包括这样的javascript:

  <script src="phonegap.js"></script>
  <script src="barcodescanner.js"></script>

In config.xml, added this: 在config.xml中,添加以下内容:

<gap:plugin name="com.phonegap.plugins.barcodescanner" />

When I set scanner variable like this it logs that there is a BarcodeScanner, and it does have a function scan , but then when I call the function scan nothing happens. 当我像这样设置扫描仪变量时,它会记录到有BarcodeScanner,并且确实具有功能scan ,但是当我调用功能scan什么也没有发生。 (the camera does not open). (相机无法打开)。

var scanner = cordova.plugins.barcodeScanner;
console.log(scanner)  // =>  BarcodeScanner

This is how I'm calling the scan function: 这就是我调用scan功能的方式:

scanner.scan( function (result) {
  ... my code here...
} );

Any ideas? 有任何想法吗? I'd really appreciate any help or pointers in how to get the barcodeScanner to work with PhoneGap. 对于如何使条形码扫描仪与PhoneGap配合使用的任何帮助或指导,我将非常感谢。

I´m having the exact same problem. 我遇到了完全相同的问题。

After I updated my App to support arm64 (iPad Air), I ran into this issue. 在更新我的应用程序以支持arm64(iPad Air)之后,我遇到了这个问题。

A work-a-round: 一轮工作:

  1. Push the hardware On/Off button. 按下硬件开/关按钮。
  2. Turn on the device again. 再次打开设备。
  3. Try starting the barcodeScanner. 尝试启动条形码扫描仪。

This worked for me - but the App will not leave my desk before the issue has been fixed properly. 这对我有用-但在问题得到正确解决之前,该应用程序不会离开我的办公桌。

The issue now exists on all of my devices (iPad Mini, iPhone 4S, iPad Air). 我的所有设备(iPad Mini,iPhone 4S,iPad Air)现在都存在此问题。

The problem was that the version from wildabeast was not compatible with PhoneGap >= 3.2.0. 问题是来自wildabeast的版本与PhoneGap> = 3.2.0不兼容。

Use this branch instead: https://github.com/phonegap-build/BarcodeScanner 请改用此分支: https : //github.com/phonegap-build/BarcodeScanner

Install with 用安装

phonegap local plugin add https://github.com/phonegap-build/BarcodeScanner

To get it to work, I had to create a brand new app, copy the www folder over, and then install the plugin. 为了使其正常工作,我必须创建一个全新的应用程序,将www文件夹复制过来,然后安装该插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM