bitpay / cordova-plugin-qrscanner

A fast, energy efficient, highly-configurable QR code scanner for Cordova apps and the browser.
MIT License
567 stars 773 forks source link

Does this plugin work with anyone? #359

Open kamhawy4 opened 2 years ago

kamhawy4 commented 2 years ago

I found issues dont never fixed . i dont know if this plugin work or dont? Does this plugin work with anyone? i will write my issue However some people wrote about this error before me. may be anybody help me.

this function wont work QRScanner.scan();

don't display any error but camera won't open

thank you for everyone.

and this is my code

"cordova-android": "^9.1.0"

"cordova-plugin-qrscanner": "^3.0.1",

// html

<button @click="qrPrep();">QR Prepare <button @click="qrScan01();">QR Scan <button @click="qrShow();">QR Show

/// js

` qrPrep: function () {

   window.QRScanner.prepare(onDone); // show the prompt
      function onDone(err, status) {
          if (err) {
              // here we can handle errors and clean up any loose ends.
              alert('error');
              console.error(err);
          }
          if (status.authorized) {
              // W00t, you have camera access and the scanner is initialized.
              // QRscanner.show()
              alert('Authorized.'); //This works.
          } else if (status.denied) {
              // The video preview will remain black, and scanning is disabled. We can
              // try to ask the user to change their mind, but we'll have to send them
              // to their device settings with `QRScanner.openSettings()`.
              alert('Denied.');
          } else {
              // we didn't get permission, but we didn't get permanently denied. (On
              // Android, a denial isn't permanent unless the user checks the "Don't
              // ask again" box.) We can ask again at the next relevant opportunity.
              alert('Not permanently denied.');
          }
      }
  },
    qrScan01:function() {
      console.log("Button clicked.");
      QRScanner.scan(displayContents); //this does not work
      //Also tried window.QRScanner - doesn't work either

      function displayContents(err, text) {
          console.log("Entered.");
          if (err) {
              // an error occurred, or the scan was canceled (error code `6`)
              console.log('error', err);
              alert('An error occurred.');
          } else {
              // The scan completed, display the contents of the QR code:
              console.log('text', text);
              alert(text);
          }
      }
  },
 qrShow:function () {
    QRScanner.show(function(status) {
        console.log(status); //this only shows status like authorized: true etc.
    });
  },`
jamesblunt1973 commented 2 years ago

It's not working for me either. my issue is: Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0 ionic 5, capacitor, angular, android

jacobg commented 2 years ago

I have a fork that hopefully brings this project up to date. Try it out: https://github.com/jacobg/cordova-plugin-qrscanner/tree/modernize

jacobg commented 2 years ago

BTW, I don't think Cordova Android in general yet supports Gradle 8. It's not an issue with this particular plugin: https://github.com/apache/cordova-android/blob/master/framework/cdv-gradle-config-defaults.json

amounous commented 2 years ago

After calling QRScanner.scan(displayContents); you have to call directly QRScanner.show(); I was also stuck before calling this method.