In my video calling app, I have followed the steps mentioned here to keep the app consistent with Callkit audio session flow. Now, after connecting to the room, if I want to enable speaker with user control using a button, I can’t seem to do so. I am using the following code to enable speaker -
do {
**try** AVAudioSession.sharedInstance().overrideOutputAudioPort(.speaker)
debugPrint("enabled speaker")
} **catch** {
debugPrint("failed to enable speaker: \\(error.localizedDescription)")
}
What I found is that port is overridden successfully but audio is not routed to speaker. And from Callkit UI speaker button, it seems that speaker is disabled after a few seconds (from SDK i think). I have also found out that setting mode to videoChat in the provided callkit example doesn’t work properly too.
Can anyone suggest me how to enable/disable speaker seamlessly according to the Callkit project example?