Cannot use the BarcodeScanner twice


Hi everyone,

Running my app on Ionic view I can’t reuse the barcode scanner process when it’s called the second time (it freeze the app).

Here is my code :

In the controller

    constructor(public navCtrl: NavController) {

    scan() {
        BarcodeScanner.scan().then((barcodeData) => {
        }, (err) => {

In the view :


<ion-content padding>
    <button ion-button full (click)="scan()">Rescan</button>

Do you know why the barcode scan freeze when it’s used the second time (when I click on the button) ? Did I miss something ?


I have an idea. It might not help but worth the try. Do NOT call native plugins from the constructor. Call the scan() method from ionViewDidEnter lifecycle hook or call it from OnInit (one of the angular2 lifecycle hook).
Ionic lifecycle events:
Angular2 lifecycle hooks:


Thanks it work like a charm !