EddyVerbruggen / nativescript-barcodescanner

🔎 NativeScript QR / barcode (bulk)scanner plugin
MIT License
293 stars 73 forks source link

Navigation doesn't work after continuousScanCallback close #242

Open lvnmdev opened 4 years ago

lvnmdev commented 4 years ago

So i used the continousScanCallback, it works but upon pressing back to close the scanner, navigation does not work anymore, modals do but any navigation doesn't.

Here's my code segment.

export function ScanBarcode(args) { const object = args.object; const page = object.page;

const barcodescanner = new BarcodeScanner();
const transaction = new Transaction();

const toasty = new Toasty({
    text: 'Barcode Scanned',
    position: 'BOTTOM',
    duration: 'SHORT',
    textColor: '#ebeef7',
    backgroundColor: '#6ce4b9'
});

try {
    barcodescanner.scan({
        formats: "QR_CODE, EAN_13",
        message: "Please align the QR Code / Barcode to scan.",
        showTorchButton: true,
        beepOnScan: true,
        fullScreen: true,
        orientation: "portrait", 
        reportDuplicates: true,
        openSettingsIfPermissionWasPreviouslyDenied: true,
        scanResult: (e) => {console.log(e)},
        continuousScanCallback: (result) => {
            setTimeout(async() => {
                if (result.format === "EAN_13") {
                    await StoredProcedure.execute('order/UpdateOrderBodyStatus.sql', result.text).then(result => {
                        toasty.show();
                    }).catch(err => {
                        console.error(err);
                    })
                }
                else if (result.format === "QR_CODE") {
                    await transaction.AddTransaction(JSON.parse(result.text)).then(() => {
                        barcodescanner.stop();
                    }).catch(err => {
                        console.error(err);
                    });
                }
            }, 100);
        },
        closeCallback: () => {
            console.log("Scanner closed")
            barcodescanner.stop();
        },
    }).then(
        result => {
            console.log('then', result);
        },
        errorMessage => { 
            console.log("No scan. " + errorMessage);
        }
    );
} catch (err) {
    console.error(err);
}

}

domzinhuu commented 4 years ago

Me too, but this problem appears with no continuousScanCallback too.

Version: "@angular/animations": "~10.0.0", "@angular/common": "~10.0.0", "@angular/compiler": "~10.0.0", "@angular/core": "~10.0.0", "@angular/forms": "~10.0.0", "@angular/platform-browser": "~10.0.0", "@angular/platform-browser-dynamic": "~10.0.0", "@angular/router": "~10.0.0", "@nativescript/angular": "~10.0.0", "@nativescript/core": "rc", "@nativescript/theme": "^2.3.3", "@nstudio/nativescript-floatingactionbutton": "^2.1.0", "core-js": "^2.6.9", "nativescript-barcodescanner": "^3.4.2", "nativescript-toast": "^2.0.0", "reflect-metadata": "~0.1.12", "rxjs": "~6.5.5", "tslib": "1.10.0", "zone.js": "~0.10.2"

DevDependencies: "@angular/cli": "~10.0.0", "@angular/compiler-cli": "~10.0.0", "@angular-devkit/build-angular": "~0.1000.2", "@nativescript/tslint-rules": "~0.0.5", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", "codelyzer": "^5.1.2", "jasmine-core": "~3.5.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.4.1", "karma-chrome-launcher": "~3.1.0", "karma-coverage-istanbul-reporter": "~2.1.0", "karma-jasmine": "~3.0.1", "karma-jasmine-html-reporter": "^1.4.2", "@nativescript/webpack": "~2.0.0", "protractor": "~5.4.3", "ts-node": "~8.3.0", "tslint": "~6.1.0", "typescript": "~3.9.0", "node-sass": "^4.7.1"

j99ht commented 3 years ago

Does anyone have a solution for this?