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

时间:2018-04-25 13:17:49

标签: ios mobile voip pjsip callkit

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

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

  • 一对一致电 (工作正常)
  • 我们可以结束并接受第二次电话 (工作正常)
  • 我们可以接听和接听电话(最多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,请帮我解决这个问题。 感谢。

1 个答案:

答案 0 :(得分:2)

接受通话时,请完成保留的操作以确保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中找到呼叫对象并取消该呼叫)
  

干杯;)