Reputation: 423
I am very new to PhoneGap and am trying to implement the barcodescanner app to execute on a button click. I have added the following to the config.xml:
<gap:plugin name="com.phonegap.plugins.barcodescanner" version="2.2.0" />
My HTML looks like this:
<!DOCTYPE html>
<html>
<head>
<title></title>
<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 type="text/css" rel="stylesheet" href="js/jQuery.mmenu-master/demo/css/demo.css" />
<link type="text/css" rel="stylesheet" href="js/jQuery.mmenu-master/dist/css/jquery.mmenu.all.css" />
<script type="text/javascript" src="js/jquery.1.11.2.min.js"></script>
<script type="text/javascript" src="js/jQuery.mmenu-master/dist/js/jquery.mmenu.min.all.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
$(document).on('click','#employeeScan',function(e) {
$("#results").html("I am now scanning");
window.plugins.barcodeScanner.scan( function(result){
$("#results").html("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}, function(error){
$("#results").html("Scanning failed: " + error);
});
});
</script>
</head>
<body>
<div id="page">
<div class="header">
</div>
<div class="content">
<button id="employeeScan">Scan Badge</button>
<div id="results"></div>
</div>
</div>
</body>
When I click the button, I see the initial "I am now scanning" text but that is it. I do not know if the plugin is configured correctly.
Upvotes: 0
Views: 546
Reputation: 110
Instead of
window.plugins.barcodeScanner.scan( function(result){
USE:
cordova.plugins.barcodeScanner.scan(function(result(){
Upvotes: 2