Barcode Scanner - Not returning anything

  • 1
  • Question
  • Updated 4 years ago
  • Answered
Hi,

I apologize in advance if this has been answered, but I have looked and looked and found nothing. I can get the Barcode scanner to invoke using the function below. However, I get a blank result, blank format, and true for cancelled after the scan takes place. Does anyone have an idea what I'm missing?

Function:

function scanBarcode() {
var scanner = cordova.require("cordova/plugin/BarcodeScanner");
scanner.scan( function (result) {

alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);

$("#tn_text").val(result.text);
}, function (error) {
alert("Scanning failed: " + error);
} );
}

Alert

We got a barcode
Result:
Format:
Cancelled: true

some config.xml entries

<!-- ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system -->

<!--<activity android:orientation="keyboardHidden" />-->

Thanks in advance.

Jeremy
Photo of Jeremy Turner

Jeremy Turner

  • 13 Posts
  • 0 Reply Likes

Posted 5 years ago

  • 1
Photo of Jeremy Turner

Jeremy Turner

  • 13 Posts
  • 0 Reply Likes
Never mind on this. We did this an older way. I used the command line interface to create a new project. Copied our code over, and now it's working.
Photo of Dev Test

Dev Test

  • 1 Post
  • 0 Reply Likes
Hello Jeremy,

can you tell me what you have done exactly. I struggle with this quite a while.

Thank you.
Best regards,
Toni