Search code examples
iosswiftcallkit

CallKit - "Touch to return to call" not removing


I am using CallKit in my project. "Touch to return to call" is still showing even when after the call is rejected by user those who called by us.

enter image description here

let provider = CXProvider(...) // this object declared globally
provider.reportCall(with: UUID(), endedAt: Date(), reason: CXCallEndedReason.declinedElsewhere)

I am using above code avoid this. But didn't worked for me.


Solution

  • To end the call, use cxendcallaction and add the cxtransaction objects. Make sure you are using the correct uuid.

    CXEndCallAction *action = [[CXEndCallAction alloc] initWithCallUUID:callUUID];
    [self.callController requestTransaction:[CXTransaction transactionWithActions:@[action]] completion:completion];