Enabling Speaker After Manually Configuring Audio Session

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?

Not an expert, but if you have followed the rest of the prerequisites in that readme, I believe you should be calling isSpeakerOutputPreferred, Documentation , rather than overrideOutputAudioPort

Documentation says isSpeakerOutputPreferred is used when isAutomaticConfigurationEnabled is true. I am setting isAutomaticConfigurationEnabled to false so it should not work. I have tried using it anyway and it doesn’t work.