Starting an outgoing call in CallKit means requesting the iOS telephony system to begin a call that was initiated by the user inside your app.
This is done using:
CXStartCallAction
wrapped inside:
CXTransaction
and sent through:
CXCallController
Outgoing calls are app-initiated actions.
The app does not directly start the call.
Instead, it asks the system:
“The user wants to start this call. Can CallKit coordinate it?”
User taps call button
↓
App creates UUID
↓
App creates CXHandle
↓
App creates CXStartCallAction
↓
App wraps action in CXTransaction
↓
CXCallController sends request
↓
System validates request
↓
CXProviderDelegate confirms start
func startOutgoingCall(to recipient: String) {
let uuid = UUID()
let handle = CXHandle(
type: .phoneNumber,
value: recipient
)
let startAction = CXStartCallAction(
call: uuid,
handle: handle
)
startAction.isVideo = false
let transaction = CXTransaction(action: startAction)
callController.request(transaction) { error in
if let error = error {
print("Failed to start call:", error.localizedDescription)
} else {
print("Outgoing call request sent")
}
}
}