cordova-plugin-inappbrowser: Unable to access camera for record video online from inappbrowser

Bug Report

Unable to access the camera while accessing the https://webcamtests.com/ URL for android and iOS ionic application

It must allow access to the Camera for record the video

It is not accessing the camera for any of the website like https://webcamtests.com/

Information

I am working on one of the Ionic project and need to access client’s website which access the camera and record the video. If we run the Website on browser, it ask for permission to access the camera and if we grant the permission, it will record the video and if we denied the permission we are facing same issue what we are facing for In-App-Browser Lib.

Command or Code

import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';

constructor(private iab: InAppBrowser) { }

openBrowser(){
    const browser = this.iab.create('https://webcamtests.com/','_blank','location=no');
  }

It is opening the browser in the application however when we visit the websites which are using the camera, it shows Steam is not available error or not able to access your camera.

For only android it is working by adding following code in src/android/InAppChromeClient.java file(However don’t know is it really only way to do this or not)

@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void onPermissionRequest(PermissionRequest request) {
request.grant(request.getResources());
}

###Some error logs Android(If we not modify src/android/InAppChromeClient.java)

[ERROR:web_contents_delegate.cc(175)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.

IOS

-  <_UIKBCompatInputView: 0x105455200; frame = (0 0; 0 0); layer = <CALayer: 0x282eb0fc0>> returned 0 width, assuming UIViewNoIntrinsicMetric
- Unbalanced calls to begin/end appearance transitions for <UIViewController: 0x105347880>
- Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service

Environment, Platform, Device

All the android, iOS mobile devices

Version information

In-App-Browser Cordova v9.0.0 (cordova-lib@9.0.1) Ionic v4 Node v12.12.0 NPM v6.14.1 Development using MAC OS Andorid Studio 3.5.2 XCode 11.3.1

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 26 (3 by maintainers)

Commits related to this issue

Most upvoted comments

Doesn’t seem like this is solved.

I’m also facing same issue as I’m using video conference meeting through Inappbrowser which is not allowing camer and microphone, Is there any solution?

did this issue resolved …if yes please tell me how to do it…its urgent i have already wasted 5 days

Use “_self” instead of “_blank”

Use the below code for getting permissions set And the permissions set for the app will applies only for the “_self”

        checkAndRequestPermissions: function () {
            var permissions = cordova.plugins.permissions;
            var list = [
                permissions.RECORD_AUDIO,
                permissions.MODIFY_AUDIO_SETTINGS,
                permissions.WRITE_EXTERNAL_STORAGE,
                permissions.RECORD_VIDEO,
                permissions.READ_EXTERNAL_STORAGE,
                permissions.CAPTURE_AUDIO_OUTPUT,
                permissions.CAMERA,
                permissions.MICROPHONE,
                permissions.CAPTURE_SECURE_VIDEO_OUTPUT,
                permissions.CAPTURE_VIDEO_OUTPUT
            ];
            permissions.hasPermission(list, this.permissionSuccess, this.permissionError);
        },
        permissionSuccess: function (status) {
            var permissions = cordova.plugins.permissions;
            var list = [
                permissions.RECORD_AUDIO,
                permissions.MODIFY_AUDIO_SETTINGS,
                permissions.WRITE_EXTERNAL_STORAGE,
                permissions.RECORD_VIDEO,
                permissions.READ_EXTERNAL_STORAGE,
                permissions.CAPTURE_AUDIO_OUTPUT,
                permissions.CAMERA,
                permissions.MICROPHONE,
                permissions.CAPTURE_SECURE_VIDEO_OUTPUT,
                permissions.CAPTURE_VIDEO_OUTPUT
            ];
            if (!status.hasPermission) {
                permissions.requestPermissions(
                    list,
                    function (status) {
                        if (!status.hasPermission) this.permissionError();
                    },
                    this.permissionError());
            }
        },
        permissionError: function () {
            console.warn('Enabling permissions failed!');
        },

The app permissions are not applied for the browser opening as “_blank”