6

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")
        }
    }
}
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Kalikanth040494
  • 452
  • 5
  • 15
  • If the callback option shows, then the call didn't end properly. So check the end call function properly. – RJV Kumar Jan 11 '18 at 05:12

2 Answers2

8

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

Kalikanth040494
  • 452
  • 5
  • 15
2

Close All Call (Swift4)

func performEndCallAction() {

    for call in self.cxCallController.callObserver.calls {

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

        cxCallController.request(transaction) { error in
            if let error = error {
                NSLog("EndCallAction transaction request failed: \(error.localizedDescription).")
                return
            }

            NSLog("EndCallAction transaction request successful")

        }

    }

}
Mohammad Razipour
  • 3,643
  • 3
  • 29
  • 49