Search code examples
javascriptandroidcordovawebrtchtml-framework-7

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


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();
} 

Solution

  • 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.