You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Communication Calling SDK发起呼叫时崩溃问题求助

Azure Communication Calling SDK 一对一呼叫崩溃排查方案

问题重现

使用Swift调用Azure Communication Calling SDK发起一对一呼叫时,触发内部崩溃,错误日志:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'

已确认callAgent和传入的CommunicationIdentifier数组非空,但崩溃仍发生。

排查与解决步骤

  • 验证参与者ID的完整性
    虽然createCommunicationIdentifier(fromRawId:)返回了非nil的实例,但需进一步确认其内部属性是否有效。添加代码打印具体类型和属性:

    let identifier = createCommunicationIdentifier(fromRawId: callee)
    debugPrint("Identifier type: \(type(of: identifier))")
    if let phoneId = identifier as? PhoneNumberIdentifier {
        debugPrint("Phone number: \(phoneId.phoneNumber ?? "nil")")
    } else if let userId = identifier as? CommunicationUserIdentifier {
        debugPrint("User ID: \(userId.id ?? "nil")")
    }
    

    如果输出中出现nil属性,说明RawId格式有误,需修正传入的callee参数格式,确保符合Azure Communication Identifier的RawId规范。

  • 显式初始化StartCallOptions
    空的StartCallOptions可能导致SDK内部默认配置处理异常,尝试显式设置必要选项:

    let options = StartCallOptions()
    // 明确配置音频选项
    options.audioOptions = AudioOptions(isMuted: false)
    // 若不需要视频,显式设置禁用
    options.videoOptions = VideoOptions(localVideoStream: nil)
    

    显式配置可避免SDK内部因默认值缺失产生nil插入数组的情况。

  • 检查SDK版本
    确认当前使用的SDK版本是否存在已知的类似崩溃问题,建议升级至最新稳定版,或回退到之前验证过的稳定版本。

  • 确保主线程调用
    SDK的呼叫启动操作需在主线程执行,添加主线程调度:

    DispatchQueue.main.async {
        self.callAgent?.startCall(participants: callees, options: options) { (call, error) in
            // 回调处理逻辑
        }
    }
    

内容的提问来源于stack exchange,提问作者Ashish P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 12:05:34