gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:10:52 24 4
gpt4 key购买 nike

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

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

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

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

  • 保持并接受时,我们可以接受没有音频的第二个电话。

  • 调用套件中的切换调用按钮已禁用。

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

We are reporting new call by following method.

- (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) {
}
}];
}

On second call It will ask user for (End & Accept) OR (Hold & Accept)

this is how we are getting second call view

When we click on hold and accept

    - (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;
}
}

This is how we are accepting second call while hold and accept. Which is working fine with no audio activated for accepted call. and following method is been called :

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

现在交换电话的按钮被禁用了。

查询:

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

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

最佳答案

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

Above is the code for hold. don't forget to do [action fulfill]

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

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

Cheers ;)

关于ios - 我们如何使用 pjsip 和 callkit 处理多个调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50023429/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com