I was doing some searching trying to get some answers on what could be causing this issue and saw an answer that said to use a serial queue to get past this issue. I am using a serial queue but still facing issues with getting VoIP notifications to come through while app is in background or in a killed state. While it is in the foreground everything runs great and as expected. I referred to this documentation and a post on here about the serial queue.
https://developer.apple.com/documentation/pushkit/pkpushregistry/1614494-init
(In the Parameters section it very briefly states that you need a serial queue).
Any help would be much appreciated. The most difficult part is that there aren't any logs for me to follow on this issue.
Here is relevant code
var voipRegistry = PKPushRegistry.init(queue: DispatchQueue(label: "voipQueue"))
self.pushKitEventDelegate = notificationHandler
self.voipRegistry.delegate = self
self.voipRegistry.desiredPushTypes = [PKPushType.voIP]
Relevant outputs:
-Running from foreground
pushRegistry:didReceiveIncomingPushWithPayload:forType:completion:
-Running from background
-Running from Killed state
In case anyone else is banging their head against a wall with this. I will provide my solution. It seems that voip notifications need to report to call kit within seconds so it has to be done right away. I was using an API call to get the call details first and then reporting the call. This will cause an error to show up that says the same thing I just explained. If you keep sending notifications without reporting right away after about 4 times Apple will block the notifications from coming in. From your notification server you will see 200 success but nothing on the app side. I had to delete the app and install again to see the error message again, then reporting the call to CallKit right after seems to work. Background and killed state. I did use a serial queue (not main). Good luck to anyone else out there facing this issue as the threads are bare bones on answers. Hope this helps.