Adding Back Tracks Does Not Work on WebRTC

We create an app with React Native WebRTC and Janus Gateway. It works as wanted. Our app is based on push to talk. So when an users in listen mode need to break microphone for other apps. And take back when anyone press to speak button.

Breaking Mic:

if (!globalTrack) {
     globalTracks = config.myStream.getTracks();
}
config.myStream.getTracks().forEach(t => {
    config.myStream.removeTrack(t);
});

Get Back the Tracks:

globalTracks.forEach(t => {
    config.myStream.addTrack(t);
});

pluginHandle.createOffer({
    media: { addVideo: true },
    success: function(jsep) {
        Janus.debug(jsep);
        pluginHandle.send({message: {audio: true, video: false}, "jsep": jsep });
    },
    error: function(error) {
        console.log("WebRTC error... " + JSON.stringify(error));
    }
});

// also I have try this:

devices = await mediaDevices.getUserMedia({audio: true, video: false})

devices._tracks.forEach(t => {
    config.myStream.addTrack(t);
}); 

pluginHandle.createOffer({
    media: {audio: {deviceId: devices._tracks[0]['id']}, replaceAudio: true},
    success: function(jsep) {
        pluginHandle.send({message: {audio: true, video: false}, "jsep": jsep});
    },
    error: function(error) {
        console.log(("WebRTC error... " + JSON.stringify(error));
    }
});

Problem :

Problem: E.g: when a call came to the phone and answered it. The user’s voice does not pass anymore even after restarting the app.

On Janus Gateway every things is normal. I think problem is about renegotiation.

  • Problem occurred only on Android phones.

Janus Gateway Log which when I speak at room:

There's a message for JANUS AudioBridge plugin
Setting muted property: true (room 20, user 2301490876606211)
Notifying participant 329012611897879 (brango)
Sending event to transport...
  >> 0 (Success)