如何在TwilioVoice iOS中禁用免提电话(Twilio可编程语音)

时间:2017-04-20 14:23:29

标签: ios twilio

当正在进行呼叫(发送或接收)时,扬声器电话已经启用,扬声器电话按钮不响应按下以将其关闭。

有没有办法在代码中切换它或在UI中切换它?我相信这个UI是Apple的核心音频电话UI。

这可以通过Twilio的快速入门演示代码来实现: https://github.com/twilio/voice-quickstart-swift

4 个答案:

答案 0 :(得分:0)

尝试以下操作强制输出到扬声器:

if !session.overrideOutputAudioPort(AVAudioSessionPortOverride.Speaker, error:&error) {
   println("could not set output to speaker")
   if let e = error {
      println(e.localizedDescription)
   }
}

答案 1 :(得分:0)

SWIFT 3.0

IList<DeliveredTaskModel> deliveredTaskModel = new List<DeliveredTaskModel>();
// lines of code 

if (materialUsed.Count > 0)
{
    foreach (var material in materialUsed)
    {
        var deliveryModel = new DeliveredTaskModel();
        deliveryModel.Info = material.SubPartCode;
        deliveryModel.Description = material.Description;
        deliveryModel.Qty = material.Qty;
        deliveredTaskModel.Add(deliveryModel);
    }
}

将输出端口覆盖为无。

答案 2 :(得分:0)

SWIFT 4

try AVAudioSession.sharedInstance().setCategory(AVAudioSession.Category.playAndRecord, mode: AVAudioSession.Mode.voiceChat, options: .mixWithOthers)
try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
try AVAudioSession.sharedInstance().setActive(true)

答案 3 :(得分:0)

您可以尝试以下代码段

func moveToVoiceCall(){

    audioDevice.block = {
        DefaultAudioDevice.DefaultAVAudioSessionConfigurationBlock()
        do {
            try AVAudioSession.sharedInstance().setMode(.voiceChat)
            try AVAudioSession.sharedInstance().overrideOutputAudioPort(.none)
        } catch {
            print(error)
        }
    }

    audioDevice.block();

}