How to use iosrtc in project?

Hi there, I already made an app with RTC using PeerJS, It works fine in web and in Android, but I cannot make it work on iOS. I am trying to use iosrtc plugin to use the navigator.mediaDevices.getUserMedia method but it does not work. It does not ask for permissions to use the camera or outputs the error. it simply does not execute navigator.mediaDevices.getUserMedia.

I installed the plugin and from what I undestand in the documentation it enables the use of WebRTC W3C JavaScript APIs directly.

Is there something else I have to do inside the app to make use of it?

getMedia() {

const constraints = {
video: true,
audio: true
};

const handleSuccess2 = (stream: MediaStream) => {
this.myStream = stream;
this.myEl.srcObject = stream;
};

const handleError2 = (error: any) => {
if (error.name === ‘ConstraintNotSatisfiedError’) {
const v = constraints.video;
// this.errorMsg(The resolution ${v.width.exact}x${v.height.exact} px is not supported by your device.);
this.errorMsg(The resolution px is not supported by your device.);
} else if (error.name === ‘PermissionDeniedError’) {
this.errorMsg('Permissions have not been granted to use your camera and ’ +
'microphone, you need to allow the page access to your devices in ’ +
‘order for the demo to work.’);
}
this.errorMsg(getUserMedia error3: ${error.name}, error);

};

navigator.mediaDevices.getUserMedia(constraints).then(handleSuccess2).catch(handleError2);

}

Just saw you actually mentioned the cordova-rtc/ cordova-plugin-iosrtc plugin. My previous comment might be misleading… I thought you meant webRTC in general. So I leave the relevant stuff here:

It seems like iOS 14.3 (which is currently in Beta 2) seems to bring webRTC to iOS.

I tried it in this Repo which worked under one condition, which I couldn’t really manage to archive with capacitor so far: It needs to served via “https://”, even for localhost. I thought this could be relevant for your case.

Thanks. I have managed to get the streamed video from the other source but I cant enable the video from the iphone, It does not ask for permission and also the streamed video pass the audio to the ear speaker not the loudspeaker of the phone.

Any Idea of how to get the getUserMedia method to work. As I said earlier the iosrtc plugin is supposed to enable that. I really cant wait for iOS 14.3

Thanks for your help.

I did it. To use the iosrtc pugin you just have to:

Add declare var cordova:any; just after the imports inside your rtc service, then use declare var cordova:any; to make it work just like in android.

After that i get the stream from the device and from the caller.

Hello,
I’ve the same probleme as you.
I’m using ionic 5 angular ios 13.3 and 13.4 and navigator.getUserMedia doesn’t work.
I receive notallowederror.
Can you tell me how did you do ?
Thanks