How to use the nativescript-barcodescanner.scan function in nativescript-barcodescanner

To help you get started, we’ve selected a few nativescript-barcodescanner examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EddyVerbruggen / nativescript-barcodescanner / demo / main-view-model.js View on Github external
DemoAppModel.prototype.scan = function (front, flip) {
    barcodescanner.scan({
      cancelLabel: "Stop scanning", // iOS only, default 'Close'
      message: "Go scan something", // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.'
      preferFrontCamera: front,     // Android only, default false
      showFlipCameraButton: flip    // Android only, default false (on iOS it's always available)
    }).then(
        function(result) {
          dialogs.alert({
            title: "Scan result",
            message: "Format: " + result.format + ",\nValue: " + result.text,
            okButtonText: "OK"
          })
        },
        function(errorMessage) {
          console.log("No scan. " + errorMessage);
        }
    )
github Appverse / Nativescript-NG2-Showcase / app / pages / codescanner / codescanner.component.ts View on Github external
public scan(format?:string) {
        if (barcodescanner.available()) {
            barcodescanner.scan({
                formats: format,   // Pass in of you want to restrict scanning to certain types; AZTEC and MAXICODE formats dont work fine 
                cancelLabel: 'Stop scanning', // iOS only, default 'Close' 
                message: 'Go scan something', // Android only, default is 'Place a barcode inside the viewfinder rectangle to scan it.' 
                preferFrontCamera: false,     // Android only, default false 
                showFlipCameraButton: true,   // Android only, default false (on iOS it's always available) 
                orientation: 'portrait'      // Android only, optionally lock the orientation to either "portrait" or "landscape" 
            }).then(
                (result)=> {
                    console.log('Scan format: ' + result.format);
                    console.log('Scan text:   ' + result.text);
                    this.result = result.format + ' ' + result.text;
                },
                (error)=> {
                    console.log('No scan: ' + error);
                }
            );