I am developing Webview with react native and facing an issue.
I have started working with peerjs to stream to mic and camera, problem is it asked me twice for permissions to the camera and mic, once in the native level and second in the webview level (prompt also shows the website address).
To prevent that, i am inserting webrtc directly on native (react-native-webrtc lib) and trying to stream to the video element inside the webrtc through injectJavaScript. Problem is it doesn't know how to work with the stream object and breaks the JS code.
I did this test on iOS only. Code:
this.webView.injectJavaScript(`
video = document.getElementById('myvid');
video.srcObject = data;
video.on("loadedmetadata", () => {
alert(0);
video.play();
});
`);
The code doesn't do anything, probably breaks the JS because I've tried to see if it continues but it stops after the line: video.srcObject = data;
Is there a way to solve it?
Thank you!