Hello together,
I am new at programming with Phonegap and are very confused by all these namespace changes and compatibility problems.
I am trying to get the simple barcodeScanner-Plugin from the git repository running in a fresh XCode-Project. I have been trying phonegap/cordova versions from 1.4.1 to 1.6 with plugins from the iOS and iPhone folder.
Cordova 1.5/1.6 doesn't work at all with the Plugin from the iOS folder. If I try to debug the js code with alerts, I get an "undefined" message at window.plugins.barcodeScanner line. I have read in an phonegap-discussion that the functions hasResource and addResource are deprecated and doesn't work no more. But they are used in the barcodescanner.js file from the iOS folder. Can this be the problem?
Cordova 1.4.1 works together with the Plugin from the iPhone folder. The app starts and the scanning mask opens. If i cancel the scanning-process everything works fine but when i scan an Barcode or QR Code the programmed alert opens and the app freezes. I cant find a working solution. Can anybody help me on this?
My index.html file looks like this:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
<meta charset="utf-8">
<script type="text/javascript" charset="utf-8" src="cordova-1.6.0.js"></script>
<script type="text/javascript" charset="utf-8" src="barcodescanner.js"></script>
<script type="text/javascript">
var scanCode = function() {
alert(window.plugin.barcodeScanner);
window.plugins.barcodeScanner.scan(
function(result) {
alert("Scanned Code: " + result.text
+ ". Format: " + result.format
+ ". Cancelled: " + result.cancelled)
}, function(error) {
alert("Scan failed: " + error)
});
}
</script>
</head>
<body>
<h1>Barcode Scanner</h1>
<a href="#" onclick="scanCode();">Scannen</a>
</body>
</html>
Thanks