Cannot read property 'scan' of undefined

  • Cocoon Version:
    What Cocoon version are you using to compile (i.e. 1.0.0)?

  • Basic description of the problem:
    I am trying to use the barcodeScanner plugin but I am getting this error: Cannot read property ‘scan’ of undefined

I think its a noob issue because I have never used an external plugin.

I am trying to access the barcodescanner this way:
function read(){
alert(‘read call’);

	if( ! window.cordova ){
		alert('cordova not ready');
		alert('cordova ready');
			  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);
				  preferFrontCamera : true, // iOS and Android
				  showFlipCameraButton : true, // iOS and Android
				  showTorchButton : true, // iOS and Android
				  torchOn: true, // Android, launch with the torch switched on (if available)
				  saveHistory: true, // Android, save scan history (default false)
				  prompt : "Place a barcode inside the scan area", // Android
				  resultDisplayDuration: 500, // Android, display scanned text for X ms. 0 suppresses it entirely, default 1500
				  formats : "QR_CODE,PDF_417", // default: all but PDF_417 and RSS_EXPANDED
				  orientation : "landscape", // Android only (portrait|landscape), default unset so it rotates with the device
				  disableAnimations : true, // iOS
				  disableSuccessBeep: false // iOS and Android

document.addEventListener('deviceready', read, false);

Any help will be appreciate.


just to be sure.
Have you added the third party plugin also to your config.xml so that the compiler adds it to the project?



This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.