'echo problem and unwanted voice cancelation in AVAudioSession

i am using avrecdorder to record voip call, below is my code , recording is working properly but echo and other unnessesory voice are coming at opponent side.

let Audiosession = AVAudioSession.init()
if #available(iOS 14.5, *) 
{
   try Audiosession.setCategory(.multiRoute,options: [.interruptSpokenAudioAndMixWithOthers,.duckOthers,.overrideMutedMicrophoneInterruption])
} else {
 // Fallback on earlier versions
}
try Audiosession.setActive(true)
let settingobj = [
                AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
                AVSampleRateKey: 44100,
                AVNumberOfChannelsKey: 2,
                AVEncoderAudioQualityKey:AVAudioQuality.high.rawValue
            ]
let audioRecorder = try AVAudioRecorder(url: URL.init(string: settings.AudiooutputURL.absoluteString ?? "")!, settings: settingobj)
audioRecorder.delegate = self
audioRecorder.isMeteringEnabled = true
audioRecorder.prepareToRecord()
audioRecorder.record()

on stop click

audioRecorder.stop()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source