I am integrating CallKit with VOIP app. I was able to make incoming and outgoing calls. I followed the step:
I have implemented the callbacks for DTMF provider delegate as shown below:
func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
print("Provider - CXPlayDTMFCallAction")
let dtmfDigts:String = action.digits
for (index, _) in dtmfDigts.characters.enumerated() {
let dtmfDigit = dtmfDigts.utf8CString[index]
print("Processing dtmfDigit:\(dtmfDigit)" )
self.softphone.dtmf(on:dtmfDigit)
}
self.softphone.dtmfOff()
// Signal to the system that the action has been successfully performed.
action.fulfill()
}
I don't hear key-press sound i.e., local dtmf sounds when I press a number on the native in-call UI during the call.
From https://developer.apple.com/reference/callkit/cxplaydtmfcallaction:
"CallKit automatically plays the corresponding DTMF frequencies for any digits transmitted over a call. The app is responsible for managing the timing and handling of digits as part of fulfilling the action."
Is this a known issue or callkit doesn't play the local dtmf key press sounds?
I was able to make it work by:
func provider(_ provider: CXProvider, perform action: CXPlayDTMFCallAction) {
print("Provider - CXPlayDTMFCallAction")
self.softphone.audioController.configureAudioSession()
let dtmfDigts:String = action.digits
for (index, _) in dtmfDigts.characters.enumerated() {
let dtmfDigit = dtmfDigts.utf8CString[index]
print("Processing dtmfDigit:\(dtmfDigit)" )
self.softphone.dtmf(on:dtmfDigit)
}
self.softphone.dtmfOff()
// Signal to the system that the action has been successfully performed.
action.fulfill()
}
Note: I added self.softphone.audioController.configureAudioSession().
-(void) configureAudioSession
{
// Configure the audio session
AVAudioSession *sessionInstance = [AVAudioSession sharedInstance];
// we are going to play and record so we pick that category
NSError *error = nil;
[sessionInstance setCategory:AVAudioSessionCategoryPlayAndRecord error:&error];
if (error) {
NSLog(@"error setting audio category %@",error);
}
// set the mode to voice chat
[sessionInstance setMode:AVAudioSessionModeVoiceChat error:&error];
if (error) {
NSLog(@"error setting audio mode %@",error);
}
NSLog(@"setupAudioSession");
return;
}