Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I end the call session on callkit from my custom ongoing call UI?

When a user end a call from the CallKit UI the app ends the call and the actual VOIP call also end. But when I end the call from my custom UI the VOIP call ends but the CallKit is still active. How do I end the CallKit session from my custom UI?

This is what happens when I press end call on the CallKit UI:

 func provider(_ provider: CXProvider, perform action: CXEndCallAction) {
     XCPjsua.shared()?.endCall()
     action.fulfill()
 }

This is what happens when I end call from my custom UI (Should I close CallKit here?):

- (void)endcall {
    [[XCPjsua sharedXCPjsua] endCall];
}
like image 248
Coder_98 Avatar asked Oct 16 '25 04:10

Coder_98


2 Answers

If you want to end the call from your custom UI you should do that through a CXTransaction:

let callController = CXCallController()

let endCallAction = CXEndCallAction(call: aUUID)
callController.request(
    CXTransaction(action: endCallAction),
    completion: { error in
        if let error = error {
            print("Error: \(error)")
        } else {
            print("Success")
        }
    })

this will cause provider(_ provider: CXProvider, perform action: CXEndCallAction) to be called.

In all other cases (i.e. remote ended, unanswered, etc... - see CXCallEndedReason) you should only report the ended call:

let provider: CXProvider

provider.reportCall(with: call.uuid, endedAt: Date(), reason: .remoteEnded)

in this case provider(_ provider: CXProvider, perform action: CXEndCallAction) will not be called.

like image 153
Marco Avatar answered Oct 18 '25 16:10

Marco


I use this code to close call

provider?.reportCall(with: PushUtility.shared.uuid!, endedAt: Date(), reason: .remoteEnded)

First save your uuid which you are using for connecting call use that uuid for end call.

like image 45
Ali Aqdas Avatar answered Oct 18 '25 16:10

Ali Aqdas