1

I want to end a phone call by callkit api. But I get this information "com.apple.CallKit.error.requesttransaction error 4". I don't know why and what happen. By the way, the phone call is real call, not a VOIP call.

CallKit CXError.h CXErrorCodeRequestTransactionErrorUnknownCallUUID 4

Prepare, enable voip for com.apple.CallKit.error.requesttransaction error 1 & create global variable CXCallController *callController enter image description here

First, I use CXCallObserver get call UUID

- (void)callObserver:(CXCallObserver *)callObserver callChanged: (CXCall *)call {
}

Followed, I use some api to end the phone and I put it in callObserver

    NSUUID *callUUID = call.UUID;
    CXEndCallAction *endaction = [[CXEndCallAction alloc] initWithCallUUID:callUUID];
    CXTransaction *transaction = [[CXTransaction alloc] initWithAction:endaction];

    [self.callController requestTransaction:transaction completion:^(NSError * _Nullable error) {
        if (error) {
            NSLog(@"EndCallAction transaction request failed: %@", [error localizedDescription]);
        } else {
            NSLog(@"EndCallAction transaction request successful");
        }
    }];

Finally, I get this. PS: The UUID is not empty. enter image description here

I have referenced How to end a call in CallKit. But no use. I have no idea. Please help or try to give some ideas how to achieve this. Thanks!

Phineas Huang
  • 813
  • 7
  • 19

3 Answers3

1

You can only use CallKit to manage VoIP calls that were established by your app. You cannot manage cellular calls or VoIP calls from other apps.

Paulw11
  • 108,386
  • 14
  • 159
  • 186
0

Apple Documentation seems to suggest that its possible to put a Telephony call on Hold https://developer.apple.com/documentation/callkit/cxcall but that doesn't seem to work for me. If it is supposed to work, it should work for Ending a call as well.

I tried the above too and even though the CallObserver gives the call UUID from the calls list, it is showing the above error.

But then wonder how this would work if you have a VOIP app and you were on an existing Telephony Call, and you want to hold/end the Telephony Call and answer the incoming call (of your VOIP app).

0

you have to just call below function by passing uuid

func performEndCallAction(uuid: UUID) {

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

    callKitCallController.request(transaction) { error in
        if let error = error {
            NSLog("EndCallAction transaction request failed: \(error.localizedDescription).")
        } else {
            NSLog("EndCallAction transaction request successful")
        }
    }
}
Hassan Kalhoro
  • 182
  • 2
  • 8