2017-08-14 10 views
-1

phonegap-plugin-qrscannerを使用してQRコードをスキャンしようとしています。私はチュートリアルの手順に従いますが、カメラはデバイスで開いていません。Ionic Qrスキャンチュートリアル

それは私のコードです:

constructor(private qrScanner: QRScanner) {} 

this.qrScanner.prepare() 
    .then((status: QRScannerStatus) => { 
     console.log('QRScanStatus status:'); 
     console.log(status); 
     if(status.authorized) { 
       // start scanning 
     let scanSub = this.qrScanner.scan().subscribe((text: string) => { 
     console.log('Scanned something', text); 

     this.qrScanner.hide(); // hide camera preview 
     scanSub.unsubscribe(); // stop scanning 
     }); 
     this.qrScanner.show(); 
     }else if(status.denied) { 
     console.log('Status denied ...'); 
     }else{ 
     console.log('Otro estado ...'); 
     } 
    }) 
    .catch((e) => { 
     console.log('Error atrapado: ', e); 
    }); 

任意のアイデア?

+0

この問題は解決しましたか? – robbannn

答えて

1

だから私の提案は機能で、あなたのコードを配置し、cordova-plugin-qrscannerをインストールし、どちらかにある、すなわちcordova-plugin-qrscanner

、あなたは別のプラグインのAPIを使用しようとしているようだ:

$ ionic cordova plugin add cordova-plugin-qrscanner 
$ npm install --save @ionic-native/qr-scanner 

か見てみましょうphonegap-plugin-barcodescannerのドキュメントを参照して、コードを適宜変更してください。

+0

なぜバーコードですか? IonicにはQRコード用のプラグインがあります。[https://ionicframework.com/docs/native/qr-scanner/]を参照してください。 – ramiromd

+0

あなた自身の質問を読んで、あなたは 'phonegap-plugin-barcodescanner'を使っていると言います。しかし、あなたは 'cordova-plugin-qrscanner'にAPIを使用しようとしています。それは動作しません。 – robbannn

+0

申し訳ありません、タイプミスでした。私はカメラが開いていると思っていますが、私の見解の後ろにあります。 – ramiromd