Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zxing-scanner not working in Cordova Web View #210

Closed
Abul4u opened this issue Jun 20, 2019 · 5 comments
Closed

zxing-scanner not working in Cordova Web View #210

Abul4u opened this issue Jun 20, 2019 · 5 comments

Comments

@Abul4u
Copy link

Abul4u commented Jun 20, 2019

I am using zxing-scanner in Angular Web App and that Web App will load in Cordova App's Web View.
Scanner working fine in Chrome(Desktop/Tablet/Mobile) but its not working in Cordova App's Web View.

Note:
Camera permission already granted to the Cordova App.

zxing-scanner askForPermission TypeError:
navigator.mediaDevices.getUserMedia is not a function(...)

@zxing/ngx-scanner I was not able to define if I have permission for camera or not. TypeError: navigator.mediaDevices.getUserMedia is not a function(...)

zxingWeb APP in Cordova APP WebView

@benbr-personal
Copy link

You don't have your permissions properly set. Do the following:

  1. Install https://www.npmjs.com/package/cordova-plugin-android-permissions
  2. Add xmlns:android="http://schemas.android.com/apk/res/android" to the <widget> tag in your config.xml
  3. Add the following snippet inside your <platform name="android"> tag in your config.xml:
<config-file parent="/manifest" target="AndroidManifest.xml">
    <uses-permission android:name="android.permission.CAMERA" />
</config-file>
  1. Add the following code to the location that you wish to access the camera inside your app:
const permissions = window.cordova.plugins.permissions;

permissions.checkPermission('android.permission.CAMERA', (status) => {
  if (!status.hasPermission) {
    permissions.requestPermission('android.permission.CAMERA', (request) => {
      console.log('Success requesting CAMERA permission:', request);
    }, (error) => {
      console.log('Failed to set permission:', error);
    });
  }
});

@odahcam
Copy link
Member

odahcam commented Jul 5, 2019

Thanks @benbrownlol.

@wstrik
Copy link

wstrik commented Jan 6, 2020

Anybody got this working on iOS?

@odahcam
Copy link
Member

odahcam commented Jan 9, 2020

I'm not sure with Cordova, but inside a PWA it's impossible until now.

@wstrik
Copy link

wstrik commented Jan 9, 2020

Hi Obahcam, thx for your reply.
PWA isn't support by iOS enough indeed, although it does work fine in a browser. But it is why I'm trying with Cordova.
I'll open a seperate issue for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants