我们如何使用pjsip和callkit处理多个调用

我们正面临着关于iOS的callKit Framework的问题。

我们必须在app中实现以下function。

  • 一对一通话(工作正常)
  • 我们可以结束并接受第二次电话会议(工作正常)
  • 我们可以保持和接听电话(最多2个电话)。
  • 我们可以在通话之间切换。
  • 保持/取消保持当前通话。

问题:我们面临的问题是:

  • 我们能够接受暂停和接受时没有音频的第二个电话。

  • 来自通话套件的切换呼叫按钮已禁用。

我们已经完成了以下实现来处理多个调用:

我们通过以下方法报告新的电话。

- (void)reportNewIncomingCallWithUUID:(nonnull NSUUID *)UUID handle:(nonnull NSString *)handle completion:(nullable void (^)(NSError *_Nullable error))completion { CXCallUpdate *update = [[CXCallUpdate alloc] init]; update.remoteHandle = [[CXHandle alloc] initWithType:CXHandleTypeGeneric value:handle]; update.hasVideo = NO; update.supportsDTMF = YES; update.supportsHolding = YES; update.supportsGrouping = YES; update.supportsUngrouping = YES; [_provider reportNewIncomingCallWithUUID:UUID update:update completion:^(NSError * _Nullable error) { completion(error); if (!error) { } }]; } 

在第二次通话时它将询问用户(结束和接受)或(保持和接受)

这就是我们获得第二个呼叫视图的方式

当我们点击暂停并接受时

  - (BOOL)provider:(CXProvider *)provider executeTransaction:(CXTransaction* )transaction { NSLog(@"executeTransaction : %@", transaction.debugDescription); BOOL callEnd = NO; BOOL callHold= NO; BOOL callAnswer = NO; NSPredicate *filter = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", [CXEndCallAction class]]; NSArray *ends = [transaction.actions filteredArrayUsingPredicate:filter]; callEnd = [ends count] >= 1; filter = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", [CXAnswerCallAction class]]; NSArray *answer = [transaction.actions filteredArrayUsingPredicate:filter]; callAnswer = [answer count] >= 1; filter = [NSPredicate predicateWithFormat:@"self isKindOfClass: %@", [CXSetHeldCallAction class]]; NSArray *hold = [transaction.actions filteredArrayUsingPredicate:filter]; callHold = [hold count] >= 1; if(callHold && callAnswer){ pjsua_set_no_snd_dev(); Call *currentCallObject = [self getCallObjectFromUUID:callAnswer.callUUID]; if (currentCallObject != nil) { pjsua_call_id callId; callId = currentCallObject._call_id; [self startAudio]; [currentCallObject answerCallWithCompletion:^(BOOL isSucceed) { if (isSucceed) { CallInfo *callForHold; callForHold = [self getCallToBeHoldFromUUID:callHold.callUUID]; if (callForHold != nil) { [callForHold holdCurrentCall]; } } }]; } return YES; }else{ return NO; } } 

这就是我们在持有和接受时接受第二次通话的方式。 哪个工作正常,没有为接受的呼叫激活音频。 以下方法被称为:

 - (void)provider:(CXProvider *)provider didDeactivateAudioSession:(AVAudioSession *)audioSession{ 

现在,已禁用交换呼叫按钮。

查询:

  • 如何解决音频问题?
  • 我们可以启用切换呼叫按钮吗?
  • 如果启用该按钮,那么在切换呼叫时将调用哪种方法?

伙计如果有人使用过callKit和pjsip,请帮我解决这个问题。 谢谢。

在接听电话时,请完成保持的操作,以确保callkit保持当前通话。 这将启用交换呼叫按钮。

不要忘记为CXCallUpdate启用以下内容:

 update.supportsHolding = YES; update.supportsGrouping = NO; update.supportsUngrouping = NO; -(void)provider:(CXProvider *)provider performSetHeldCallAction:(CXSetHeldCallAction *)action{ if (action.onHold) { [callForHold holdCurrentCall]; }else{ [callForHold unHoldCurrentCall]; } [action fulfill]; } 

以上是保留代码。 别忘了做[行动履行]

当您单击交换按钮时,CXHeldCall将被触发2次:

  • 一个要保持的呼叫(从callUUID中查找呼叫对象并保持该呼叫)
  • 第二次调用是Unhold(从callUUID中查找调用对象并取消该调用)

干杯;)