twilio / voice-quickstart-ios

Twilio Voice Quickstart for iOS with Swift
MIT License
183 stars 97 forks source link

How to route custom ringtone audio to speaker? #536

Closed bennnjamin closed 2 months ago

bennnjamin commented 1 year ago

I saw a similar comment about this here but no solution https://github.com/twilio/twilio-voice-ios/issues/85#issuecomment-950894282.

Simply calling toggleAudioRoute(toSpeaker: true doesn't do anything during ringing with a custom ringtone. In fact, you get this error:

AVAudioSession setAggregatedIOPreference:error: Error Domain=NSOSStatusErrorDomain Code=560030580 "Operation not permitted while session has running audio I/Os" UserInfo={NSLocalizedDescription=Operation not permitted while session has running audio I/Os}

What is the correct way to allow the user to activate the speaker while the call is still ringing using a custom ringtone?