I have been building small app with Intel XDK. I try to open Phonegap Barcode scanner but when launch button is clicked nothing happens. My goal is to scan a QR code and open inAppBrowser link containing result data. I have both Device (cordova-plugin-device) and Barcode Scanner (phonegap-plugin-barcodescanner) plugins installed with permissions for camera and flash.
Here is my code:
<script type="text/javascript">
document.addEventListener("deviceready", scanNow, false);
function scanNow() {
cordova.plugins.barcodeScanner.scan(
function (result) {
// alert("We got a barcode\n" +
// "Result: " + result.text + "\n" +
// "Format: " + result.format + "\n" +
// "Cancelled: " + result.cancelled);
window.open("http://www.example.com?qr=" + result.text, '_system', 'location=no');
},
function (error) {
alert("Error: " + error);
});}
</script>
And this is the launch button:
<a role='button' onclick="scanNow();">Scan</a>
EDIT: I solved the problem by adding this link to a dummy script to my index page head.
<script src="cordova.js"></script>