Exception in "new Device()" in mediasoup-client on react native

Hi Mediasoup Team,

I have installed mediasoup-client in react-native project on windows 10.

I have improted Device like:
import { Device } from ‘mediasoup-client’;

then called:

try {
device = new Device();
} catch (error) {
if (error.name === ‘UnsupportedError’) {
console.error(‘browser not supported’);
}
}

Getting error.name === ‘UnsupportedError’ error.

Any help or hint will be greatly appreciated.

Have you actually read the docs?

I got it. Thanks, Great documentation.

can you please help me to fix this error, i am getting this error mediasoupClient.registerGlobals is not a function
my mediasoup version is “mediasoup-client”: “^3.17.1” and webrtc version is “react-native-webrtc”: “^124.0.7”,
and this is my code

import {
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
MediaStream,
MediaStreamTrack,
mediaDevices,
} from ‘react-native-webrtc’;
import * as mediasoupClient from ‘mediasoup-client’;
mediasoupClient.registerGlobals({
RTCPeerConnection,
RTCIceCandidate,
RTCSessionDescription,
MediaStream,
MediaStreamTrack,
mediaDevices,
});

try {
device = new mediasoupClient.Device();
} catch (error) {
if (error.name === ‘UnsupportedError’) {
console.error(‘browser not supported’);
}
}

Why are you passing all those objects to registerGlobals() function?

what is the correct way, do i just need to call this function without any parameters
like this registerGlobals()
but when i am adding this line i am getting this error mediasoupClient.registerGlobals is not a function

Check the signature of that function. Anyway, you will of course get the same error using it one way or another because those arguments are of course ignored.

Enable full debugs in mediasoup-client and show the full logs.

@ibc bro it is fixed now this is overview about issue and how i fixed that
Error: mediasoup-client threw UnsupportedError: device not supported because it couldn’t detect React Native WebRTC support.

Root Cause: The library requires RTCRtpTransceiver to be globally available to identify React Native environment, but it wasn’t imported or set.

Fix: Added RTCRtpTransceiver import from react-native-webrtc and set it globally before importing mediasoup-client. This allows the library to properly detect React Native and use the ReactNative106 handler for WebRTC communication.

Then you should report an issue in react-native-webrtc project or write a PR for it because this is a bug. registerGlobals() should also put RTCRtoTransceiver in global. Will you do it?

Not sure which version of react-native-webrtc you are using but RTCRtpTransceiver is already added to global when calling registerGlobal():

actually i am using this version- webrtc”: “^124.0.7”,
and mediasoup-client - “^3.17.1”