Skype for business iOS SDK:无法启动音频服务

Skype for business iOS SDK: unable to start audioservice

我正在集成 Skype 的 iOS SDK,当我尝试从对话助手启动音频服务时。

do {
    try self.conversationHelper.conversation.audioService.start()
}
catch {
    print(error.localizedDescription)
}

我收到这个错误。音频既不通过也不出去。 (但视频服务运行良好。)

2016-11-12 21:22:00.012 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioModality.cpp:230 CUcmpAudioModality::start(AudioType) called.
2016-11-12 21:22:00.014 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioModality.cpp:259 CUcmpAudioModality::start(AudioType, CUriString) called.
2016-11-12 21:22:00.015 test-skype[669:1aa91fc40] INFO APPLICATION CUcmpAudioVideoModality.cpp:2799 CUcmpAudioModality::queryCapability on StartVoIP returned false because modality state is InConversation
2016-11-12 21:22:00.017 test-skype[669:1aa91fc40] ERROR APPLICATION CUcmpAudioModality.cpp:267 Unable to start audio with error (587726849)

我该如何解决这个问题?请帮忙。

我设法找到了解决办法。我需要先初始化 AVAudioSession 并将类别设置为 AVAudioSessionCategoryPlayAndRecord 才能使其正常工作。

let audioSession: AVAudioSession = AVAudioSession.sharedInstance()
do{
    try audioSession.setCategory(AVAudioSessionCategoryPlayAndRecord)
}
catch let errorForCategory as Error{
    print(errorForCategory.localizedDescription)
}
do{
    try audioSession.setMode(AVAudioSessionModeVoiceChat)
}
catch let errorForMode as Error {
    print(errorForMode.localizedDescription)
}

编辑:如果您打算在视频聊天中使用 Airplay,您需要将模式设置为 AVAudioSessionModeVideoChat,如本文档中所述。 https://developer.apple.com/library/content/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/AudioSessionBasics/AudioSessionBasics.html

do {
    try audioSession.setMode(AVAudioSessionModeVideoChat)
}
catch let errorForMode as Error {
    print(errorForMode.localizedDescription)
}