CallKit - No sound when answering second call (VoIP) and put first call (GSM) on hold

92 Views Asked by At

I have a React Native app that is capable of making outbound and inbound VoIP calls. Inbound calls works fine in every app's state (active, background, locked & background, locked & killed) and i can hear the caller. However, when the device is in active GSM call and it receives VoIP call, i have 2 options:

  1. End & Accept - audio works fine in this case
  2. Hold & Accept - call will connect, however the audio session is not working - i can't hear the caller and caller can't hear me.

Weird thing is that the call stays in CallKit screen. When single inbound call is handled and device is unlocked, my app will be opened automatically.

Similar issue happens when I have active VoIP call and i receive GSM call. If i choose Hold & Accept, audio session for GSM call. However, if i choose Swap to hold the GSM call and go back to VoIP call, audio will not work. This is happening on iOS, couldn't tested it on Android.


My stack is the following:

As soon as i receive VoIP notification, i report to callkit new incoming call:

- (void)pushRegistry:(PKPushRegistry *)registry didReceiveIncomingPushWithPayload:(PKPushPayload *)payload forType:(PKPushType)type withCompletionHandler:(void (^)(void))completion
{
  // --- Retrieve information from your voip push
  NSString *pushType = payload.dictionaryPayload[@"type"];
  NSString *uuid = payload.dictionaryPayload[@"callUuid"];

  // --- Process the received push
  [RNVoipPushNotificationManager didReceiveIncomingPushWithPayload:payload forType:(NSString *)type];

  // --- Report new incoming call to callkit
  if( [pushType isEqualToString: @"incoming-call"] && uuid){
      NSString *callTitle = payload.dictionaryPayload[@"callTitle"];
      NSString *callSubtitle = payload.dictionaryPayload[@"callSubtitle"];
      [RNCallKeep reportNewIncomingCall: uuid
                                  handle: callSubtitle
                              handleType: @"generic"
                                hasVideo: NO
                     localizedCallerName: callTitle
                         supportsHolding: YES
                            supportsDTMF: YES
                        supportsGrouping: NO
                      supportsUngrouping: NO
                             fromPushKit: YES
                                 payload: nil
                   withCompletionHandler: completion];
  }

  // --- Execute completion handler
  completion();
}

When i receive answerCall event from CallKeep, i will initiate the audio session. As mentioned before, this works well for every single inbound call cases.

Also tried starting audio session right before reporting new incoming call as suggested here - didn't help.

Double checked logs from incall-manager lib when initiating audio session. The Category is correctly set to AVAudioSessionCategoryPlayAndRecord and Mode to AVAudioSessionModeVoiceChat.

One weird note is that when i focus my app and trigger hold with in-app controls for couple of second and then unhold, the audio starts working... In-app controls basically triggers CallKit ops but as i don't see Hold on CallKit screen, i need to focus my app.

Thank you for any help in advance!


Seems like a duplicate of this thread. However, it is 6 years old and there is no solution. This issue is really weird as the big apps like Messenger, WhatsApp and Viber have this case working correctly.

0

There are 0 best solutions below