0

I've implemented CallKit in my VoIP app and everything's fine except one scenario :

When A VoIP call interrupt a phone Call and the user select "End & Answer", the phone call is ended, the VoIP call is answered but after a few seconds the sound is lost.

This behavior doesn't happen when the phone call is put on hold or if the VoIP call interrupt another VoIP call (even from another VoIP app)

To restore the sound you need to pause and resume the call.

Anyone reproduces this issue or has an idea ?

Thanks in advance !

1 Answers1

0

When you are answer call.. Check wheather is audio session activated or not, after that you need to activate your call media state.

- (void)provider:(CXProvider *)provider performAnswerCallAction:(CXAnswerCallAction *)action {

   NSLog(@"Provider perform Answer Call Action");

   // Retrieve the instance corresponding to the action's call UUID
   SIPCall *call = [_callManager callWithUUID:action.callUUID];
   if (!call) {
       [action fail];
       return;
   }

   /*
   Configure the audio session, but do not start call audio here, since it must be done once
   the audio session has been activated by the system after having its priority elevated.
   */
   [[AudioManager sharedManager] configureAudioSession];

   // Trigger the call to be answered via the underlying network service.
   [call answer];

   // Signal to the system that the action has been successfully performed.
   [action fulfill];
}

Also check end call method.

- (void)provider:(CXProvider *)provider performEndCallAction:(CXEndCallAction *)action {
   NSLog(@"Provider perform End Call Action");
   // Retrieve the Voifinity PBX instance corresponding to the action's call UUID
   SIPCall *call = [_callManager callWithUUID:action.callUUID];
   if (!call) {
      [action fail];
      return;
   }

   // Stop call audio whenever ending the call.
   //[[AudioManager sharedManager] disableSoundDevices];

   // Trigger the call to be ended via the underlying network service.
   [call hangUp];

   // Signal to the system that the action has been successfully performed.
   [action fulfill];

   // Remove the ended call from the app's list of calls.
   [_callManager removeCall:call];

}

And also add to check audio session activate or deactivate or not. You call audio should be activated only and only after audio session activation. Add below delegate to track of audio sessions.

//Activate session

- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession {
   NSLog(@"Received: %s",__FUNCTION__);
}

//Deactivate session

- (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession {
NSLog(@"Received: %s",__FUNCTION__);
}
Irfan Khatik
  • 146
  • 7