Callkit loudspeaker bug / how WhatsApp fixed it?

前端 未结 5 1357
别那么骄傲
别那么骄傲 2021-02-02 10:08

I have an app with Callkit functionality. When I press the loudspeaker button, it will flash and animate to the OFF state (sometimes the speaker is set to LOUD but

5条回答
  •  渐次进展
    2021-02-02 10:44

    Above answer is correct, "VoiceChat" mode ruin everything.

    Swift 4 example for WebRTC. After connection was established call next

    let rtcAudioSession = RTCAudioSession.sharedInstance()
    rtcAudioSession.lockForConfiguration()
    do {
        try rtcAudioSession.setCategory(AVAudioSession.Category.playAndRecord.rawValue, with: 
        AVAudioSession.CategoryOptions.mixWithOthers)
        try rtcAudioSession.setMode(AVAudioSession.Mode.default.rawValue)
        try rtcAudioSession.overrideOutputAudioPort(.none)
        try rtcAudioSession.setActive(true)
    } catch let error {
        debugPrint("Couldn't force audio to speaker: \(error)")
    }
    rtcAudioSession.unlockForConfiguration()
    

    You can use AVAudioSession.sharedInstance() as well instead RTC

提交回复
热议问题