我有一个VoIP应用程序,其中调用工作正常。
但是,当我们有一个活动的VoIP呼叫并且用户收到一个正常的PSTN呼叫时,活动的VoIP呼叫将变为空白-两边都听不到音频。
为了解决此问题,我们决定以编程方式结束新的传入呼叫,我成功地检测到了传入的PSTN呼叫。但当我试图结束通话时,我得到错误消息:
EndCallAction transaction request failed: The operation couldn’t be completed. (com.apple.CallKit.error.requesttransaction error 4.)
错误代码4是指CXErrorCodeRequestTransactionErrorUnknownCallUUID
。
下面是我的代码:
// called during initialization
self.callObserver = [[CXCallObserver alloc] init];
[self.callObserver setDelegate:self queue:dispatch_get_main_queue()];
- (void)callObserver:(nonnull CXCallObserver *)callObserver callChanged:(nonnull CXCall *)call {
// isCallInProgress static variable tracks if a VoIP call is active and I verified its value - works as expected
if(isCallInProgress) {
if(!call.isOutgoing && !call.hasConnected && !call.hasEnded) {
NSLog(@"*** New incoming call detected while a call is in progress - so reject it");
dispatch_async(dispatch_get_main_queue(), ^{
CXEndCallAction *endCallAction = [[CXEndCallAction alloc] initWithCallUUID:call.UUID];
CXTransaction *transaction = [[CXTransaction alloc] initWithAction:endCallAction];
CXCallController *controller = [[CXCallController alloc] init];
[controller requestTransaction:transaction completion:^(NSError *error) {
if (error) {
NSLog(@"*** EndCallAction transaction request failed: %@", [error localizedDescription]);
}
else {
NSLog(@"*** EndCallAction transaction request successful");
}
}];
});
}
}
}
接下来我可以尝试什么?
1条答案
按热度按时间qij5mzcb1#
只是张贴的解决方案,我决定继续下去,这为我们解决了问题。
我决定监听AudioSession中断,这是由系统根据设备发生的情况触发的:
以下代码是Twilio特有的,它解决了当前呼叫在新来电振铃时变为空白的问题: