I am developing a VoIP app that uses Twilio for telephony. The issue i am facing is that if the AVAudioSession is interrupted while a call is in progress, for example by an incoming FaceTime call, then i am not able continue using Audio session after the interruption ends. The call does not disconnect , but no sound is audible and the microphone is not recording anything either.
I have registered for the AVAudioSessionInterruptionNotification and in the notification handler, I do the following :
// get the user info dictionary
NSDictionary *interuptionDict = notification.userInfo;
// get the AVAudioSessionInterruptionTypeKey enum from the dictionary
NSInteger interuptionType = [[interuptionDict valueForKey:AVAudioSessionInterruptionTypeKey] integerValue];
// decide what to do based on interruption type here...
switch (interuptionType)
{
case AVAudioSessionInterruptionTypeBegan:
DLog(@"Audio Session Interruption case started.");
[self setAudioSessionActive:NO];
break;
case AVAudioSessionInterruptionTypeEnded:
{
DLog(@"Audio Session Interruption case ended.");
[self setAudioSessionActive:YES];
break;
}
default:
DLog(@"Audio Session Interruption Notification case default.");
break;
}
// Activate or deactivate the app's audio session
- (void)setAudioSessionActive:(BOOL)active
{
BOOL success = NO;
NSError *error = nil;
success = [[AVAudioSession sharedInstance] setActive:active error:&error];
if (error)
{
DLog(@"Error setting audio session : %@", [error description]);
}
else if (success)
{
DLog(@"Audio session state set successfully :")
}
}
I do not get any errors but the ongoing call just doesn't work.
I have read the Audio session programming guide , Human interface guidelines for audio and other audio related apple documentation. I believe I am following the correct steps. Please give any suggestions as what I might be missing here.