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];
}
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With