BarcodeScanner Plugin

Deprecated for Cordova 9.0 or higher. Please use the PhoneGap BarcodeScanner Plugin .

BarcodeScanner Plugin (the built-in plugin on Monaca Cloud IDE) can't be used with Android version 6 or higher and it may also not work with Cordova 6.5 projects for iOS platform.

Enable Plugin in Monaca

  1. From the IDE menu, go to Configure → Cordova Plugin Settings .

  2. Under Available Plugins section, hover over the BarcodeScanner plugin and click Enable button.

BarcodeScanner Demo

Here is a simple example demonstrating how to use the BarcodeScanner plugin with Monaca:

<!DOCTYPE HTML>
<html>
<head>
<title>Barcode Scanner DEMO</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no">
<script src="components/loader.js"></script>
<link rel="stylesheet" href="components/loader.css">
<script type="text/javascript">
function scanBarcode() {
window.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>
</head>
<body>
<hr> BarcodeReader DEMO <hr><br>
<input type="button" onClick ="scanBarcode()" value ="Scan" />
</body>
</html>

See Also: