【问题标题】:How can we handle multiple calls with pjsip and callkit我们如何使用 pjsip 和 callkit 处理多个调用
【发布时间】:2018-04-25 13:17:48
【问题描述】:

我们正面临一个关于 iOS 的 callKit 框架的问题。

我们必须在应用中实现以下功能。

  • 一对一通话(工作正常)
  • 我们可以结束并接受第二次通话(工作正常)
  • 我们可以保留和接听电话(最多 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) {
    }
}];     
}

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

this is how we are getting second call view

当我们点击保持并接受时

    - (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 ,请帮帮我。 谢谢。

【问题讨论】:

    标签: ios mobile voip pjsip callkit


    【解决方案1】:

    在接听电话时,请完成保持操作以确保 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];
            }
    

    以上是保持的代码。不要忘记做[actionfulfill]

    当你点击交换按钮时,CXHeldCall会被触发2次:

    • 要保持一个呼叫(从 action 的 callUUID 中找到呼叫对象并保持该呼叫)
    • 要取消保持的第二次呼叫(从操作的 callUUID 中查找呼叫对象并取消保持该呼叫)

    干杯 ;)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-13
      • 1970-01-01
      • 2018-09-16
      • 1970-01-01
      • 2023-03-07
      • 2018-12-23
      • 2018-12-27
      • 1970-01-01
      相关资源
      最近更新 更多