fix callkit for ios14

This commit is contained in:
Danmei Chen 2021-03-30 16:22:36 +02:00
parent ee19cce8ea
commit 0bf5f0dfd3
2 changed files with 18 additions and 1 deletions

View file

@ -248,6 +248,7 @@ import AVFoundation
providerDelegate.callInfos.updateValue(callInfo, forKey: uuid)
providerDelegate.uuids.updateValue(uuid, forKey: "")
setHeldOtherCalls(exceptCallid: "")
requestTransaction(transaction, action: "startCall")
}else {
try? doCall(addr: sAddr, isSas: isSas)
@ -385,7 +386,14 @@ import AVFoundation
@objc func setHeld(call: OpaquePointer, hold: Bool) {
let sCall = Call.getSwiftObject(cObject: call)
let callid = sCall.callLog?.callId ?? ""
if (!hold) {
setHeldOtherCalls(exceptCallid: sCall.callLog?.callId ?? "")
}
setHeld(call: sCall, hold: hold)
}
func setHeld(call: Call, hold: Bool) {
let callid = call.callLog?.callId ?? ""
let uuid = providerDelegate.uuids["\(callid)"]
if (uuid == nil) {
@ -397,6 +405,14 @@ import AVFoundation
requestTransaction(transaction, action: "setHeld")
}
@objc func setHeldOtherCalls(exceptCallid: String) {
for call in CallManager.instance().lc!.calls {
if (call.callLog?.callId != exceptCallid && call.state != .Paused && call.state != .Pausing && call.state != .PausedByRemote) {
setHeld(call: call, hold: true)
}
}
}
}
class CoreManagerDelegate: CoreDelegate {

View file

@ -87,6 +87,7 @@ class ProviderDelegate: NSObject {
let callInfo = callInfos[uuid]
let callId = callInfo?.callId
Log.directLog(BCTBX_LOG_MESSAGE, text: "CallKit: report new incoming call with call-id: [\(String(describing: callId))] and UUID: [\(uuid.description)]")
CallManager.instance().setHeldOtherCalls(exceptCallid: callId ?? "")
provider.reportNewIncomingCall(with: uuid, update: update) { error in
if error == nil {
if CallManager.instance().endCallkit {