phonegap / phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
MIT License
1.27k stars 1.39k forks source link

If the current application does not have permission to access the camera ,android 5.1 always success callback #517

Open jyz1508 opened 6 years ago

jyz1508 commented 6 years ago

Expected Behaviour

If the current application does not have permission to access the camera , the error callback should be executed

Actual Behaviour

The camera will be turned on, indicating a problem with the camera , the success callback is always executed with data result as: Object {cancelled: true, text: "", format: ""}

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

Android 5.1

(Android) What device vendor (e.g. Samsung, HTC, Sony...)

MI meizu

Cordova CLI version and cordova platform version

cordova 7.0.1

Plugin version

6.0.8

Sample Code that illustrates the problem

  window.cordova.plugins.barcodeScanner.scan((result)=>{
      if(!result.cancelled){
        callback(result.text);
      }else{
        alert(JSON.stringify(result))
      }
    },(error)=>{
       alert("Scanning failed: " + error);
    },
    {
        ...
    }
  );

Object {cancelled: true, text: "", format: ""}

But in android 7.0 , the error callback will be executed , the error data is "Illegal access"

amirhosein93 commented 5 years ago

can not work by cordova-android-firebase-gradle-release