我正在使用VOIP应用。该应用程序与CallKit正常工作。
如果闹钟在通话中发生,我将面临一个问题。每当警报停止发射(音频中断结束)时,我们都会尝试在AVAudioSession上设置setActive :.但它始终给出代码1701737535的错误,即。 'ENT?'。
当我尝试初始化音频单元时,会发生同样的错误。 没有使用CallKit,它工作正常。
任何人在音频中断结束时都会遇到激活音频会话的问题。
我在同一场景中得到了不同的错误'!pri'56017449,但这次由于Native Phone应用程序而发生中断。
问题是100%可复制的。试过很多热门&线程,延迟或调用setActive:YES,而不调用setActive:YES。但没有运气。
总结这里:
获取错误1701737535即。 “ENT?如果由于报警导致中断。
获取错误561017449即。 '!pri'如果由于原生呼叫而中断
仅在将CallKit与VIOP一起使用时进行复制。
任何人的帮助。
答案 0 :(得分:0)
我遇到了同样的问题,我发现并与我一起工作的解决方案是在报告新呼叫之前启用音频会话。
// 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 })
答案 1 :(得分:0)
我按照以下方式修复了它-希望这会有所帮助
注册 AVAudioSessionInterruptionNotification (Objective-C):
中断开始时将呼叫置于保持状态,中断结束时将音频会话设为活动状态并取消保持呼叫。
- (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;
}
}