5

I am working with VOIP app. The app is working fine with CallKit.

I am facing an issue if alarm fires within call. Every time when alarm stop firing (Audio Interruption ends), we are trying to setActive: on AVAudioSession. But it always gives an error with code 1701737535 ie. 'ent?'.

The same error occurs when I am trying to initialize Audio Unit. Without using CallKit it's working fine.

Anybody faced issue with activating Audio Session when Audio Interruption ends.

I am getting different error '!pri' 561017449 in the same scenario but this time Interruption occurred because of the Native Phone app.

Issues are 100% replicable. tried with many hit & trails like thread, delay or calling setActive:YES and without calling setActive:YES. But no luck.

Summarising here :

  1. Getting error 1701737535 ie. 'ent?' if interruption because of ALARM.

  2. Getting error 561017449 ie. '!pri' if interruption because of Native Call

Replicating only if using CallKit with VIOP.

Anybody help.

Kiran Sarvaiya
  • 1,318
  • 1
  • 13
  • 37

3 Answers3

1

I've run into the same issue, the solution I've found and worked with me is to enable Audio session before reporting your new call.

// Activate audio session
  do {
    try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord, mode: AVAudioSessionModeVoiceChat, options: [.mixWithOthers, .allowBluetoothA2DP])
    try AVAudioSession.sharedInstance().setActive(true)
  } catch {
  }
  provider.reportNewIncomingCall(with: currentCallID, update: update, completion: { error in })
Elsammak
  • 1,102
  • 10
  • 26
  • Yes I am done the same thing for a first call reported. BUT what if a call is already running and we receive another call from other app like Skype or native call. – Raju Panwar Mar 07 '19 at 06:46
  • You can check Apple documentation for this part here https://developer.apple.com/library/archive/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/HandlingAudioInterruptions/HandlingAudioInterruptions.html#//apple_ref/doc/uid/TP40007875-CH4-SW5 – Elsammak Mar 11 '19 at 01:35
  • hi bro, i still got error "Error Domain=NSOSStatusErrorDomain Code=561017449" when setting like u, can u help? – famfamfam Feb 06 '21 at 12:12
  • here is error : Failed to configure `AVAudioSession`: Error Domain=NSOSStatusErrorDomain Code=561017449 "(null)" "Error setting AVAudioSession category: Error Domain=NSOSStatusErrorDomain Code=561017449 \"(null)\"" – famfamfam Feb 06 '21 at 12:12
0

I fixed it in the following way- Hope this helps

  1. Register for AVAudioSessionInterruptionNotification (Objective-C):

  2. When interruption began put the call on hold and when interruption ends set the audio session active and unhold the call.

    - (void)interruption:(NSNotification*)notification {
      // 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: {
           NSLog(@"Audio Session Interruption case started.");
           // hold call using callkit CXTransaction
           [[CallManager shared] setHold:YES];
         }
         break;
    
         case AVAudioSessionInterruptionTypeEnded: {
          NSLog(@"Audio Session Interruption case ended.");
          AVAudioSession *audioSession = [AVAudioSession sharedInstance];
          NSError *error = nil;
          [audioSession setActive:YES error:&error];
         // unhold call using callkit CXTransaction
          [[CallManager shared] setHold:NO];
       }
       break;
    
       default:
         NSLog(@"Audio Session Interruption Notification case default.");
         break;
      }
    }
    
K_Mohit
  • 528
  • 3
  • 17
0

don't use the AVAudiosession category option 'mixwithothers'. In my case I removed that option while setting the category and it started working.

jjpp
  • 1,298
  • 1
  • 15
  • 31