79246118

Date: 2024-12-03 02:41:40
Score: 0.5
Natty:
Report link

I tried reconfiguring the audio when answering a call, but an error occurred during setActive, preventing the configuration from succeeding.

func provider(_ provider: CXProvider, perform action: CXAnswerCallAction){
    
    let audioSession = AVAudioSession.sharedInstance()
    do {
        try audioSession.setActive(false)
        try audioSession.setCategory(.playAndRecord, mode: .voiceChat, options: [.defaultToSpeaker])
        try audioSession.setActive(true, options: [])
    } catch {
        print("Failed to activate audio session: \(error)")
    }
    
    action.fulfill()

}

The error is

Error Domain=NSOSStatusErrorDomain Code=561017449 "Session activation failed" UserInfo={NSLocalizedDescription=Session activation failed}

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Kelly