Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
no provider for BarcodeScanner

The code is as follows:


    import { Component } from '@angular/core';
    import { NavController, Platform } from 'ionic-angular';
    import { TranslateService } from '@ngx-translate/core';
    import { BarcodeScanner } from '@ionic-native/barcode-scanner';

    @Component({
        selector: 'page-home',
        templateUrl: 'home.html'
    })
    export class HomePage {
        constructor(public navCtrl: NavController, private translate: TranslateService, private barcodeScanner: BarcodeScanner) {

        }
        //Switch language 
       changelanguage() {
            let browserLang = this.translate.currentLang;
            this.translate.use(browserLang.match(/en/) ? 'zh' : 'en');
        }
        //Scan test
        ScanCode() {
            this.barcodeScanner.scan()
                .then((result) => {
                    console.log(result);
                })
                .catch((error) => {
                    alert(error);
                });
        }
    }

Error Picture:

enter image description here

Reference:https://ionicframework.com/docs/native/barcode-scanner/



new questions arose:
According to Suraj recommendations, the prompt "plugin_not_installed"

Error Picture:
enter image description here
enter image description here development environment: Visual Studio 2017

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You need to set the scanner as provider in app.module.ts

import { BarcodeScanner } from '@ionic-native/barcode-scanner';

@NgModule({
  ...

  providers: [
    ...
    BarcodeScanner
    ...
  ]
  ...
})
export class AppModule { }

Reference: Add Plugins to Your App's Module here

UPDATE: From your package.json it looks like you have installed older ionic-native - 2.4.1.Remove it and do:

npm install --save @ionic-native/core
over 4 years ago · Santiago Trujillo Relatório

0

I have same issue with ionic cli 3.9.2 & solved using npm i @ionic-native/barcode-scanner@beta --save.

import { BarcodeScanner } from "@ionic-native/barcode-scanner/ngx";

@NgModule({
  ...

  providers: [
    ...
    BarcodeScanner
    ...
  ]
  ...
})
export class AppModule { }
over 4 years ago · Santiago Trujillo Relatório

0

I got same issue at android device after installing ionic cordova plugin add phonegap-plugin-barcodescanner --save which error message is plugin_not_installed. Just added CAMERA_USAGE_DESCRIPTION variable inside phonegap-plugin-barcodescanner tag at config.xml and working :)

<plugin name="phonegap-plugin-barcodescanner" spec="^7.0.1">
    <variable name="CAMERA_USAGE_DESCRIPTION" value=" " />
</plugin>
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda