我使用CallKit,在运行时传出调用时我也调用此函数
private func startCall(handle: String, video: Bool = false, uuid: UUID) {
let handle = CXHandle(type: .phoneNumber, value: handle)
let startCallAction = CXStartCallAction(call: uuid, handle: handle)
startCallAction.isVideo = video
let transaction = CXTransaction()
transaction.addAction(startCallAction)
requestTransaction(transaction)
}
private func requestTransaction(_ transaction: CXTransaction, completion: ((_ error: Error?) -> Void)? = nil) {
callController.request(transaction) { error in
if let error = error {
debugPrint("Error requesting transaction", error.localizedDescription, transaction.actions)
} else {
debugPrint("Requested transaction successfully")
}
completion?(error)
}
}
但是我在交易请求期间收到错误。
请求事务时出错" "无法完成操作。(com.apple.CallKit.error.requesttransaction error 2.(
我该如何解决它?
更新:当设备收到来电时,所有交易都会执行而不会出错。
这是我
的错误,因为我没有初始化ProviderDelegate
,初始化后一切正常。