Search code examples
iosnotificationsvoipcallkitpushkit

VOIP notification with CallKit is not invoking reportIncomingCall when app is inactive killed state


It's a video calling app. I have implemented VoIP notifications to receive a video call. On receiving VoIP notification, I am using CallKit to call reportNewIncomingCall().

When I minimise the app, I receive the incoming call and the flow works fine. But when I kill the app, I am not getting the incoming call. Any idea why? I also noticed that when I tap and open the app next time, it gets crashed :

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 callback.'

This says that I am not posting reportNewIncomingCall. But I am already doing it and getting call when app is minimized.

func pushRegistry(_ registry: PKPushRegistry,
                  didReceiveIncomingPushWith payload: PKPushPayload,
                  for type: PKPushType,
                  completion: @escaping () -> Void) {

    provider.reportNewIncomingCall(with: uuid, update: update) { error in
     
    }
    completion()
}

Only on killed state, I don't get the calls. What else to be done to receive calls in killed state? Please help.


Solution

  • Have you tried to call the pushRegistry completion handler inside the reportNewIncomingCall completion handler?

    func pushRegistry(_ registry: PKPushRegistry,
                      didReceiveIncomingPushWith payload: PKPushPayload,
                      for type: PKPushType,
                      completion: @escaping () -> Void) {
    
        provider.reportNewIncomingCall(with: uuid, update: update) { error in
            completion() // <----
        }
    }
    

    Even if it's not clear in the documentation, I think it's the correct way to handle a new incoming call.