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
相关产品推荐
相关产品推荐

