我遇到了一个问题,因为呼叫未接通,但是此CallKit UI通知(或任何被称为的呼叫)仍在后台并且无法杀死它。很明显,由于cal未连接,我无法打电话给performEndCallAction
,也无法打电话给uuid。
还有其他方法可以杀死/消除这种情况吗?
以下是我的开始通话操作代码。
发生错误时,将记录以下日志:
callButtonTapped
执行通话
2019-01-13 20:36:40.739368 + 0000 [6789:930051] StartCallAction事务请求成功
在报告电话之前
reportCall之后
// MARK: Call Kit Actions
func performStartCallAction(uuid: UUID, handle: String) {
let callHandle = CXHandle(type: .generic, value: handle)
let startCallAction = CXStartCallAction(call: uuid, handle: callHandle)
let transaction = CXTransaction(action: startCallAction)
callKitCallController.request(transaction) { error in
if let error = error {
NSLog("StartCallAction transaction request failed: \(error.localizedDescription)")
// Try ending the call if the green bar disappears
DispatchQueue.main.async {
let alert = UIAlertController(title: "Call failed", message: "Something went wrong. Please close app, restart and try again. Contact support if problem persists.", preferredStyle: UIAlertController.Style.alert)
let okAction = UIAlertAction(title: "Ok", style: UIAlertAction.Style.default) { (action) in
}
alert.addAction(okAction)
alert.view.tintColor = .purpleColour
// alert.view.layoutIfNeeded() //avoid Snapshotting error
self.present(alert, animated: true, completion: nil)
}
return
}
NSLog("StartCallAction transaction request successful")
let callUpdate = CXCallUpdate()
callUpdate.remoteHandle = callHandle
callUpdate.supportsDTMF = true
callUpdate.supportsHolding = true
callUpdate.supportsGrouping = false
callUpdate.supportsUngrouping = false
callUpdate.hasVideo = false
print("Before reportCall")
self.callKitProvider.reportCall(with: uuid, updated: callUpdate)
print("After reportCall")
}
}
答案 0 :(得分:1)
您必须使用Callkit请求结束交易。可以解决您的问题
let endCallAction = CXEndCallAction(call: uuid)
let transaction = CXTransaction()
callController.request(transaction) { error in
if let error = error {
// End call transaction failed
} else {
// End call transaction succeeded. this will hide the green color bar
}
}