RTCPeerConnection event 'ontrack' not work

I’m try implement a video call, but i don’t receive the RTCPeerConnection.ontrack event, in my React Native App, only on web system, I also verified if exists a method to implement it in React Native App, but i don’t finded

Someone can me help?

Someone can me help here???

I have create the post yesterday,
and nobody even visualized, i need help!!!

I was able to use this example to get it going on my react Native app I had to use a a device it won’t work on an emulator or simulator not sure if this will help you but check it out https://github.com/baconcheese113/react-native-webrtc-minimal

1 Like

Thanks @cryptotractor, i executed with another way the stream, see you how i did use the plugin https://github.com/react-native-webrtc/react-native-webrtc

stream_start(isCaller) {
    let configuration = {
        "iceServers": [
            {url: "stun:opasuite13.ixcsoft.com.br:3478"},
            {username: "opasuite", url: "stun:opasuite13.ixcsoft.com.br", credential: "opasuite"}
        ]
    };
    global.pc = new RTCPeerConnection(configuration);
    global.pc.onicecandidate = (event) => {
        if (event.candidate) {
            global.webview.postMessage(JSON.stringify({
                tipo: 'stream_ice',
                candidate: event.candidate
            }));
        }
    };

    global.pc.onaddstream = function (e) {
        global.WebRTCView.setState({videoURLClient: e.currentTarget._remoteStreams[0].toURL()});
    };

    global.pc.addStream(global.localStream);

    if (isCaller) {
        global.webview.postMessage(JSON.stringify({
            tipo: 'stream_aceita'
        }));

        global.pc.createOffer().then(this.createDescription).catch((error) => {
            console.log(error);
        })
    }

    global.webview.postMessage(JSON.stringify({
        tipo: 'stream_cancela_conexoes'
    }));
}

Below is my code when I receive the stream. I used this, because the “ontrack” does not is implemented in the react-native-webrtc plugin

global.pc.onaddstream = function (e) {
        global.WebRTCView.setState({videoURLClient: e.currentTarget._remoteStreams[0].toURL()});
    };

One more turn, I have to thank for your solution! Thanks @cryptotractor !!!

onaddstream works on mobile devices. Its deprecated, but works.