SpaceX
SpaceX

Reputation: 2890

How can I simulate an Outgoing call using iOS Callkit

I have gone through the iOS CallKit documentation, the below is the code provided by Apple under the section 'Making Outgoing Calls'. When I try and call the function startOutGoingCall() nothing happens i.e. I don't see any outgoing call UI.

Could someone please suggest me how I could trigger a native outgoing call UI.

func startOutGoingCall(){
    let uuid = UUID()
    let handle = CXHandle(type: .emailAddress, value: "[email protected]")

    let startCallAction = CXStartCallAction(call: uuid)
    startCallAction.destination = handle

    let transaction = CXTransaction(action: startCallAction)
    callController.request(transaction) { error in
        if let error = error {
            print("Error requesting transaction: \(error)")
        } else {
            print("Requested transaction successfully")
        }
    }
}

EDIT: Added the delegate method from my code

func provider(_ provider: CXProvider, perform action: CXStartCallAction) {
        logMessage(messageText: "provider:performStartCallAction:")

        /*
         * Configure the audio session, but do not start call audio here, since it must be done once
         * the audio session has been activated by the system after having its priority elevated.
         */
        localMedia?.audioController.configureAudioSession(.videoChatSpeaker)

        callKitProvider.reportOutgoingCall(with: action.callUUID, startedConnectingAt: nil)

        performRoomConnect(uuid: action.callUUID, roomName: action.handle.value) { (success) in
            if (success) {
                provider.reportOutgoingCall(with: action.callUUID, connectedAt: Date())
                action.fulfill()
            } else {
                action.fail()
            }
        }
    }

Upvotes: 2

Views: 1656

Answers (1)

user102008
user102008

Reputation: 31313

There is no outgoing UI you get from CallKit. When you make an outgoing call, your app is open, and therefore, it is your app that should show the UI.

Upvotes: 9

Related Questions