In AVAudioSession, I am using the option "AVAudioSessionCategoryOptionDefaultToSpeaker" with the category "AVAudioSessionCategoryPlayAndRecord", as the documentation says. In iOS 15 and before, it worked when the app in foreground and in background
In iOS 16, it works in foreground, but when the app is in background, the sound is sent to the receiver, not to de speaker, and I get this in the log:
AVAudioSession_iOS.mm:2374 Failed to set category, error: '!int'
Is this a bug or is it the intended behaviour? Is there any workaround or way to force the iPhone to send the sound to the speaker when the app is in background in iOS 16?