简体   繁体   English

'NSInternalInconsistencyException',原因:'杀死应用程序,因为它在收到 PushKit VoIP 推送后从未向系统发布传入呼叫

[英]'NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push

Unable to resolve this issue tried many things.无法解决此问题尝试了很多方法。 Tried debugging but it keeps showing this error尝试调试,但一直显示此错误

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push.' *** 由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“正在杀死应用程序,因为它在收到 PushKit VoIP 推送后从未向系统发布传入呼叫。”

func pushRegistry(_ registry: PKPushRegistry,didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) {
    let dict = payload.dictionaryPayload
    if let handleDict = dict["handle"] as? NSDictionary {
        self.callDict = handleDict
        
        let config = CXProviderConfiguration(localizedName: "App")
        config.iconTemplateImageData = UIImage(named: "user_circle")!.pngData()
        config.ringtoneSound = "iphoneRingtone.mp3"
        config.includesCallsInRecents = true;
        config.supportsVideo = true;
        
        let callProvider = CXProvider(configuration: config)
        callProvider.setDelegate(self, queue: nil)
        
        let callUpdate = CXCallUpdate()
        let phoneNumber = CXHandle(type: .phoneNumber, value: "SoCircle")
        callUpdate.remoteHandle = phoneNumber
        callUpdate.hasVideo = true
        let callUUID = UUID()
        
        // Report the call to CallKit
        callProvider.reportNewIncomingCall(with: callUUID, update: callUpdate, completion: { (error) in
            completion()
        })
    }
    completion()
}

There are two main reasons why you get that error.您收到该错误的主要原因有两个。

  1. As you may know, you always have to report a new incoming call when receiving a VoIP push.您可能知道,在收到 VoIP 推送时,您总是需要报告新的来电。 If, for any reason, the value contained in dict["handle"] is nil or is not an NSDictionary , you fail to report a new incoming call and so you get the error.如果出于任何原因, dict["handle"]中包含的值是nil或不是NSDictionary ,则您无法报告新的来电,因此您会收到错误消息。

  2. The completion() should be called only after you successfully reported a new incoming call, so inside the completion handler of reportNewIncomingCall as you've done.只有在您成功报告了一个新的来电后,才应调用completion() ,因此在您所做的reportNewIncomingCall的完成处理程序中。 The problem is the completion() that you call outside the if .问题是您在if之外调用的completion() Given that reportNewIncomingCall is an asynchronous method, the completion() outside the if will be called before the reportNewIncomingCall has completed, hence the system will think that you've failed to report a new incoming call.鉴于reportNewIncomingCall是一个异步方法,在reportNewIncomingCall完成之前会调用if之外的completion() ,因此系统会认为您未能报告新的来电。 So, just remove the completion() outside the if .因此,只需删除if之外的completion()即可。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 原因:“杀死应用程序,因为它在收到 PushKit VoIP 推送回调后从未向系统发布传入呼叫。” - reason: 'Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push callback.' CallKit reportNewIncomingCall 完成调用但仍然出现“正在终止应用程序,因为它从未发布来电......”崩溃 - CallKit reportNewIncomingCall completion called but still getting "Killing app because it never posted an incoming call ..." crash 由于未捕获的异常“NSInternalInconsistencyException”原因而终止应用程序:“PushKit” - Terminating app due to uncaught exception 'NSInternalInconsistencyException' reason: 'PushKit' Pushkit VoiP推送通知唤醒应用程序执行时间 - Pushkit VoiP push notifications wake up app execution time iOS VoIP推送通知(PushKit) - iOS VoIP push notifications (PushKit) IOS 应用程序在强制关闭后收到 pushkit voip 通知时崩溃 - IOS app crashing when recieving pushkit voip notification after force close 即使启用了“请勿打扰”设备,如何为 VoIP 推送呼叫显示传入的 CallKit window? - How to show incoming CallKit window for VoIP push call even if the device “Do not Disturb” is enabled? Callkit 来电未在旧 iphone 的背景中显示 (Pushkit/Callkit) - Callkit incoming call not displayed in background on older iphones (Pushkit/Callkit) PushKit 通知在通话结束后到达 - PushKit notification arriving after call has ended 由于暂停动画和 NSInternalInconsistencyException 导致应用程序崩溃 - App crashing because of paused animation and NSInternalInconsistencyException
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM