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

Azure Communication Calling终止状态调用CallKit方法崩溃求助

崩溃原因排查与解决方案

崩溃提示+[ACSCallClient reportIncomingCall:callKitOptions:withCompletionHandler:]: unrecognized selector sent to class,核心是调用的类方法在当前使用的Azure Communication Calling SDK中不存在或无法被正确识别,以下是具体排查步骤:

1. 验证SDK版本兼容性

微软官方文档中用于终止状态下的reportIncomingCall(with:callKitOptions:completionHandler:)类方法是较新版本SDK才支持的特性,旧版本可能仅提供实例方法。请:

  • 检查Podfile中AzureCommunicationCalling的版本,执行pod update AzureCommunicationCalling升级到最新稳定版
  • 对照官方文档确认当前SDK版本是否支持终止状态下的类方法调用逻辑

2. 确认类名与方法签名正确性

崩溃日志中显示的目标类是ACSCallClient,但代码中调用的是CallClient:

  • 若CallClient是自定义类型别名,需确认其指向的是ACSCallClient而非其他类型
  • 尝试直接使用ACSCallClient.reportIncomingCall(...)调用,避免别名导致的类识别错误

3. 检查应用终止状态下的SDK加载情况

应用被终止状态下,SDK动态库可能未完成加载,导致类方法无法被识别:

  • 确保在推送回调didReceiveIncomingPushWith中,先完成SDK的基础初始化(极简初始化即可),再调用来电上报方法
  • 检查项目Link Binary With Libraries设置,确认AzureCommunicationCalling.framework已正确添加,且Embed & Sign选项已开启

4. 验证参数类型匹配

虽然崩溃源于方法未找到,但参数类型不匹配也可能导致方法签名不匹配:

  • 确认CallKitOptions的初始化参数ProviderDelegate.createCXProvideConfiguration()返回的是合法的CXProviderConfiguration实例
  • 检查PushNotificationInfo.fromDictionary()解析出的callNotification结构是否符合SDK要求的格式

补充代码调整建议

尝试修改代码,直接使用ACSCallClient并确保参数、回调逻辑正确:

func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
    let dictionaryPayload = payload.dictionaryPayload
    print("dictionaryPayload: \(NSDictionary(dictionary: dictionaryPayload))\n")
    
    if type == .voIP {
        guard let callNotification = PushNotificationInfo.fromDictionary(payload.dictionaryPayload) else {
            completion()
            return
        }
        let config = ProviderDelegate.createCXProvideConfiguration()
        let callKitOptions = CallKitOptions(with: config)
        
        // 直接使用ACSCallClient而非别名
        ACSCallClient.reportIncomingCall(with: callNotification, callKitOptions: callKitOptions) { error in
            if error == nil {
                print("Killed state reportNewIncomingCall was succesful.\n")
            }
            completion() // 务必调用completion,避免系统强制终止进程
        }
    } else {
        completion()
    }
}

内容的提问来源于stack exchange,提问作者sa.sathish

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.11 01:31:20