Home > Net >  WebRTC onicecandidate not getting called in cordova android, but is getting called in browser
WebRTC onicecandidate not getting called in cordova android, but is getting called in browser

Time:01-03

I am working on a file sharing project which works on WebRTC, Cordova and Framework7. My code works perfectly fine in a browser but whenever I try to run the same code through an android emulator with Cordova the WebRTC onicecandidate function never seems to get called and I don't get any error messages. If possible I don't want to use any third party libraries and just reuse the same javascript code I already wrote.

function createPeerConn() {
let conf = {
    iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
};
myConn = new RTCPeerConnection(conf, { optional: [] });
myConn.onicecandidate = function (event) {
    if (event.candidate) {
        socket.emit("candidate", event.candidate);
        console.log("create peer con called.")
    }
};
openDataChannel();
} 

CodePudding user response:

That would be because RTCIceServers.urls is not supported by ANDROID Webview as per https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls

CodePudding user response:

The issue was that I still had the cordova-webrtc plugin installed which seemed to switch around some scopes. After removing this plugin everything works as expected.

  • Related