diff --git a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java index 1b759f69c..03ae9b0e1 100644 --- a/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java +++ b/android/src/main/java/com/oney/WebRTCModule/PeerConnectionObserver.java @@ -591,6 +591,8 @@ public void onRemoveTrack(RtpReceiver receiver) { params.putInt("pcId", this.id); params.putString("receiverId", receiver.id()); + remoteTracks.remove(receiver.id()); + webRTCModule.sendEvent("peerConnectionOnRemoveTrack", params); }); }; diff --git a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m index fb9beeb1f..5d968d83b 100644 --- a/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m +++ b/ios/RCTWebRTC/WebRTCModule+RTCPeerConnection.m @@ -922,6 +922,8 @@ - (void)peerConnection:(RTC_OBJC_TYPE(RTCPeerConnection) *)peerConnection params[@"pcId"] = peerConnection.reactTag; params[@"receiverId"] = rtpReceiver.receiverId; + [peerConnection.remoteTracks removeObjectForKey:rtpReceiver.receiverId]; + [self sendEventWithName:kEventPeerConnectionOnRemoveTrack body:params]; }); }