我们如何使用PJSIP和CallKit处理多个呼叫



我们面临着关于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) {
    }
}];     
}

在第二个通话中

这就是我们获得第二个通话视图

的方式

当我们单击" hold并接受

"时
    - (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的Calluuid中找到呼叫对象并保留该呼叫(
  • 第二个呼叫要成为不持有的呼叫(从Calluuid of Action and Unhold thit Call中找到呼叫对象(

欢呼;(

最新更新