Integrating Inappbrowser with Barcodescanner

Asked

Viewed 19 times

0

Hi, I have a problem I can’t solve. I am using the inAppBrowser plugin and I need that when the user clicks on a given button inside the generated browser, the plugin is closed and simultaneously open a QR code reader.

What I’ve tried to do:

Since it is an internally generated browser, I have implemented libraries that open the camera and read by themselves. However, when the page opens with inappBrowser I receive a denied permission exception. Thinking it was just a camera permission I added the following setting:

Androidmanifest

 <uses-permission android:name="android.permission.CAMERA" />

home ts.

constructor
  (
    private camera: Camera,
    private androidPermissions : AndroidPermissions,
    private inAppBrowser: InAppBrowser
  ) {}
  ionViewWillEnter(){
    this.verificapermissao();
  }
  verificapermissao(){
    const options: InAppBrowserOptions = {
      clearcache:'yes',
      hardwareback:'yes',
      mediaPlaybackRequiresUserAction:'yes'
    }
    console.log(options)

    this.androidPermissions.requestPermission(this.androidPermissions.PERMISSION.CAMERA).then(
      result => {
        console.log('Has permission?',result.hasPermission)
        this.inAppBrowser.create('meuURL', '_self', options)
      },
      err => this.verificapermissao()
    );
  }

I used the Androidpermissions plugin to force the user to allow access to camera, however without success.

What I need now:

As I said earlier I need to get the app to close inAppBrowser and open the reader, when the reading is closed, the user is redirected to a url with the data received by the scanner passed by parameters. If this is not possible I need to at least be able to give the permission for inAppBrowser’s internal browser.

Development environment:

Ionic:

   Ionic CLI                     : 6.15.0 (C:\Users\micro-85\AppData\Roaming\npm\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 5.5.2
   @angular-devkit/build-angular : 0.1000.8
   @angular-devkit/schematics    : 10.0.8
   @angular/cli                  : 10.0.8
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.1.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 9 other plugins)

Utility:

   cordova-res : 0.15.3
   native-run  : 1.3.0

System:

   NodeJS : v14.15.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.14.9
   OS     : Windows 10


  • You mean to say that you are at every moment entering the err => this.verificapermissao()? Or is it some error message coming specifically from barcode.xhtml?

  • First of all thanks for the comment, this is just to force the person to accept the permission because when they click be made the permission request again. But this didn’t work because when I open the Barcode library I receive on the console an Exception message of permission denied. I was wondering if somehow I could pause inappBRowser to open the mobile reader.

  • Well, I’m not sure that the permission propagates to a domain outside the local domain of the application, I don’t know exactly why it had to do so instead of using directly embedded in the project, as in the example: https://ionicframework.com/docs/native/barcode-scanner/ -- there is some reason to be using an external web page?

  • A webview application was developed and so we needed to include it in the app. Would you know how to stop appInBrowser when you click on a button in html ? That would be enough for me, because then I would proceed to another url

  • Hérick, I’m rusty from Cordova and co, but it’s almost certain that this is something inappbrower be limited, because if I remember this would have to be solved in the "java" part, but I will not go into detail, what I found that might solve your problem is this: https://github.com/jverlee/cordova-plugin-inappbrowser-camera

  • Likewise, thank you very much.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.