我已经在我的VoIP应用程序中实现了CallKit,除了一种情况外,一切都很好:
当VoIP呼叫中断电话呼叫并且用户选择"结束和应答"时,电话呼叫结束,VoIP呼叫得到应答,但几秒钟后声音丢失。
当电话呼叫处于保持状态或 VoIP 呼叫中断另一个 VoIP 呼叫(甚至来自另一个 VoIP 应用)时,不会发生此行为
要恢复声音,您需要暂停并恢复通话。
有人重现此问题或有想法吗?
提前感谢!
当您接听电话时。检查是否激活了音频会话,之后您需要激活呼叫媒体状态。
- (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];
}
还要检查结束调用方法。
- (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];
}
并添加以检查音频会话是否激活或停用。您的呼叫音频应仅激活,并且仅在音频会话激活后激活。添加以下委托以跟踪音频会话。
激活会话
- (void)provider:(CXProvider *)provider didActivateAudioSession:(AVAudioSession *)audioSession {
NSLog(@"Received: %s",__FUNCTION__);
}
停用会话
- (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession {
NSLog(@"Received: %s",__FUNCTION__);
}