2

I am new to the react js. Here I am trying to access the mobile camera in the app. Here,

I am trying to use the getUserMedia . I am able to access the camera in the android device. But not able to access in the IOS.

So, I am using react for this.

if (!('getUserMedia' in navigator.mediaDevices)) {
            navigator.mediaDevices.getUserMedia = function (constraints) {
                var getUserMedia = navigator.webkitGetUserMedia || navigator.mozGetUserMedia;

                if (!getUserMedia) {
                    return Promise.reject(new Error('getUserMedia is not implemented!'));
                }

                return new Promise(function (resolve, reject) {
                    getUserMedia.call(navigator, constraints, resolve, reject);
                });
            }
        }
        navigator.mediaDevices.getUserMedia({
            video: { facingMode: 'user', width: 1200, height: 600 },
            audio: true
        }).then((stream) => {
            console.log('recording started');
            this.setState({
                cameraAccessGranted: true,
            });
            return this.startRecording(stream)
        }).

Can any one please help me with this ?

Thanks in advance .

ganesh kaspate
  • 1
  • 9
  • 41
  • 88
  • what error do you get ? Open the web inspector ( https://developer.apple.com/library/archive/documentation/AppleApplications/Conceptual/Safari_Developer_Guide/GettingStarted/GettingStarted.html ) while your device is plugged into your computer and let us know what error you get – G-Man Jul 10 '19 at 12:45
  • Possible duplicate of [Ionic + Capacitor - PWA Mobile Camera Access on iOS - Works in Safari - But not when from Home Screen icon](https://stackoverflow.com/questions/56974939/ionic-capacitor-pwa-mobile-camera-access-on-ios-works-in-safari-but-not) – abraham Jul 11 '19 at 13:41
  • The frameworks are different but I believe the cause may be the same. – abraham Jul 11 '19 at 13:42

1 Answers1

0

It doesn't matter if it is React or not, WebRtc is not dependent on framework. Have you tried to check examples from https://webrtc.github.io/samples/src/content/devices/input-output/ on your android? For me it works well