Search code examples
iosswiftcallkit

How to remove callback option UI of CallKit after ending the call


In my app i'm using CallKit for incoming call. There is no outgoing call feature in the app. Everything is fine but when the receiver or dailer ends the call it shows the CallKit UI with call back option. I don't want to show callback option, how can I do it?

My code for ending the call

func end(call: SpeakerboxCall) {

    let endCallAction = CXEndCallAction(call: call.uuid)
    let transaction = CXTransaction()
    transaction.addAction(endCallAction)

    requestTransaction(transaction, action: "endCall")

}

private func requestTransaction(_ transaction: CXTransaction, action:
    String = "") {

    callController.request(transaction) { error in
        if let error = error {
            print("Error requesting transaction: \(error)")
        } else {
            print("Requested transaction \(action) successfully")
        }
    }
}

Solution

  • I have solved it. I was force quitting the CallKit where the transaction is not correctly completing.

     AppDelegate.shared.providerDelegate?.provider.reportCall(with: call.uuid, endedAt: nil, reason: CXCallEndedReason.remoteEnded)
    

    We need to set endedAt to nil and reason to remoteEnded