Proper iOS 13 PushKit VoIP integration for Calls

Hi Devs,


I'm developing a Social networking app which includes audio call feature. I integrated with SocketIO + WebRTC for this audio call. I'm receiving audio call by two ways.

  • Socket call when socket is connected & active
  • VoIP call by default irrespective of socket is connected or not.


FYI, Why i had two ways of receiving call as mentioned above,

  • Enabled VoIP by default, because sometimes socket call is unresponsive and never show call at that time.
  • Enabled socket when app is in foreground, to ensure that call is received in case of MissingDeviceToken/BadDeviceToken errors occurred for VoIP push.


Considering iOS 13 guidelines for VoIP usage, I followed below steps for integration.

  1. When app is killed or socket not connected, will get VoIP call and responding with provider.reportNewIncomingCall(). So here no issue for VoIP usage.
  2. When socket is connected, will get both socket call & VoIP call. But socket call will get instantly before getting VoIP call. So here's what i did:
    1. Responded socket call with provider.reportNewIncomingCall().
    2. After a little delay will get VoIP push for the same call which is already invoked by socket. Here, I should respond this VoIP push with CallKit. But i have already invoked the call. So, I used below code to handle.
      • provider.reportCall(with: call.uuid, updated: update) with same uuid & update used for socket call initiation.
      • Hope, this VoIP call also responded with CallKit and there's no issue in VoIP blocking/app termination.


Question 1 : Is this a proper way of handling above issue ?


===========================================================================================================


As per my app requirement, there's should be one active call at a time from my app.


Consider, I'm in active call and one more incoming call is received via VoIP. So here, I don't want to show the additional call. So I'm ignoring the VoIP push for the additional call. But it leads to this crash "Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP push callback."


Question 2 : How to handle above mentioned scenario ?


===========================================================================================================



Kindly post your suggestions.

I have similar scenarios where I need to ignore a voip notification silently:


1. A voip call comes to the wrong user (maybe due to some issue on my server).

2. A voip call comes when the phone is in a locked state (no access to user defaults makes me unable to retrieve stored user data to connect the call).


How should we handle these scenarios?

@Balaji did you figure out how to handle those scenarios?
Proper iOS 13 PushKit VoIP integration for Calls
 
 
Q