简体   繁体   English

带有两个来电的CallKit

[英]CallKit with two incoming calls

I develop a VoIP app with CallKit. 我使用CallKit开发了VoIP应用。

In the case that the user receives two incoming calls and he/she accepts one of them the other one will be closed. 如果用户收到两个来电,而他/她接受其中一个,则另一个将被关闭。

For example report both incoming calls: 例如,报告两个来电:

reportInComingCall uuid: 70D506FB-6A9D-4111-8828-35DB8F330A26  
reportInComingCall uuid: 129A6D67-AC6A-480E-BCD7-ED14F7961CE5  

When the user accepts one of them I get this actions from CallKit: 当用户接受其中之一时,我将从CallKit收到以下操作:

perform action: CXEndCallAction uuid: 129A6D67-AC6A-480E-BCD7-ED14F7961CE5  
perform action: CXAnswerCallAction uuid: 70D506FB-6A9D-4111-8828-35DB8F330A26 

Q: Is it possible to accept one call without closing the other one? 问:是否可以在不关闭另一个呼叫的情况下接受一个呼叫?

At the end I need the following scenario: When I accept one call the other one stays on hold until I hung up the first call. 最后,我需要以下情形:当我接听一个电话时,另一个保持通话,直到挂断第一个电话。 CallKit shows me then the other one that I can accept it. CallKit告诉我另一个我可以接受它。

Ralph 拉尔夫

You need to set to CXProviderConfiguration that the app allows call grouping and multiple calls, like 您需要将CXProviderConfiguration设置为该应用程序允许通话分组和多个通话,例如

let configuration = CXProviderConfiguration(localizedName: applicationName)
configuration.supportsVideo = supportsVideo
configuration.supportedHandleTypes = [.phoneNumber]
configuration.maximumCallGroups = 3
configuration.maximumCallsPerCallGroup = 2 /// 2 calls max per call group. Excluding host call

Also, you need to set CXCallUpdate when receiving the incoming call to tell CXProvider that the incoming call can be held/un-held and grouped 另外,您需要在接收来电时设置CXCallUpdate ,以告知CXProvider来电可以保持/不保持并分组

let callUpdate = CXCallUpdate()
callUpdate.supportsGrouping = true
callUpdate.supportsUngrouping = true
callUpdate.supportsHolding = true

Use that update each time you are about to report a new incoming call to CXProvider 每次您要向CXProvider报告新的来话呼叫时都使用该更新

The system will let the user decide how to resolve the issue. 系统将让用户决定如何解决问题。 Based on the choice, it will wrap up multiple actions into a CXTransaction. 根据选择,它将多个动作包装到CXTransaction中。 For example, if the user chooses to end the ongoing call, and answer the new one, the system will create a CXEndCallAction for the former and a CXStartCallAction for the latter. 例如,如果用户选择结束正在进行的呼叫并应答新的呼叫,则系统将为前者创建一个CXEndCallAction,为后者创建一个CXStartCallAction。 Both actions will be wrapped into a transaction and sent to the provider, which will process them individually. 这两个动作将被包装到一个事务中并发送给提供者,提供者将对其进行单独处理。 So if your app already knows how to fulfil the individual requests, there's no further action required! 因此,如果您的应用程序已经知道如何满足各个请求,则无需采取进一步措施!

You can test it by resolving the scenario above; 您可以通过解决上述情况进行测试; the list of calls will reflect your choice. 通话清单将反映您的选择。 The app will only process one audio session at a time. 该应用一次只能处理一个音频会话。 If you choose to resume a call, the other will be put on hold automatically. 如果您选择恢复通话,另一个将自动保持。

For more info you can follow that tutorial 有关更多信息,您可以按照该教程进行操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM