> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# VICall

Class that represents a call and provides the API to manage it.

@objc class VICall

## Properties

### callKitUUID

@objc var callKitUUID: UUID?

CallKit UUID that may be used to match an incoming call with a push notification received before.

Always nil for outgoing calls on a [VICall](/api-reference/iossdk/calls/vicall) instance creation.

For outgoing calls it is recommended to set [CXStartCallAction.callUUID](https://developer.apple.com/documentation/callkit/cxstartcallaction) value to this property on handling CXStartCallAction

### callUpgradeHandler

@objc var callUpgradeHandler: ((@escaping ([VICallUpgradeDecision](/api-reference/iossdk/calls/vicallupgradedecision)) -> Void) -> Void)?

Triggered when the remote participant enables video during an audio call, allowing the application to accept or reject switching the call to video.

The handler receives a callback that should be invoked exactly once with a configured [VICallUpgradeDecision](/api-reference/iossdk/calls/vicallupgradedecision) object:

* [accept()](/api-reference/iossdk/calls/vicallupgradedecision#symbol-e42376a92ceee6af) — enables receiving the remote video.
* [acceptAndSend(localVideoStream:completion:)](/api-reference/iossdk/calls/vicallupgradedecision#symbol-1745cea1f091cc96) — enables receiving and start sending the provided local video stream.
* [reject()](/api-reference/iossdk/calls/vicallupgradedecision#symbol-8d46a7f1018f543d) — keeps the call audio-only and declines the remote video.

If this property is nil (the default), the upgrade is accepted automatically and video receiving is enabled.

The handler should provide a decision within 20 seconds. If it does not, the call upgrade is rejected automatically and [callUpgradeTimeoutHandler](/api-reference/iossdk/calls/vicall#symbol-14dad8123e057b3b) is invoked.

If the call has already been upgraded to video, [callUpgradeHandler](/api-reference/iossdk/calls/vicall#symbol-116c25a32daa1d14) is not invoked when the remote participant enables video again.

This handler is executed on the delegateQueue queue.

> **Note**
>
> An audio call is one that is established with [localVideoStream](/api-reference/iossdk/calls/vicallsettings#symbol-6fd7a38891511931) is `nil` and [receiveVideo](/api-reference/iossdk/calls/vicallsettings#symbol-45621f12c82c3938) is `false`.

> **Note**
>
> The handler is not invoked if video receiving enables automatically. For example, when [localVideoStream](/api-reference/iossdk/calls/vicallsettings#symbol-6fd7a38891511931) is set but [receiveVideo](/api-reference/iossdk/calls/vicallsettings#symbol-45621f12c82c3938) is `false` at the call start. In such cases, video receiving enables automatically without invoking the handler.

### callUpgradeTimeoutHandler

@objc var callUpgradeTimeoutHandler: (() -> Void)?

Triggered when [callUpgradeHandler](/api-reference/iossdk/calls/vicall#symbol-116c25a32daa1d14) does not provide a decision within 20 seconds.

Use this handler to dismiss any upgrade request presented to the user or to notify the user that the call upgrade times out.

When the timeout expires, the SDK rejects the upgrade automatically and the call remains audio-only. No further action is required in this handler.

This handler is executed on the delegate queue. It is optional and is never invoked when [callUpgradeHandler](/api-reference/iossdk/calls/vicall#symbol-116c25a32daa1d14) is not set.

### delegate

@objc weak var delegate: [VICallDelegate](/api-reference/iossdk/calls/vicalldelegate)?

Call delegate.

### direction

@objc let direction: [VICallDirection](/api-reference/iossdk/calls/vicalldirection)

Call direction.

### duration

@objc var duration: TimeInterval \{ get }

Call duration in seconds.

### id

@objc var id: String \{ get }

Call id.

### isMuted

@objc var isMuted: Bool \{ get set }

Whether the audio is muted.

### isOnHold

@objc var isOnHold: Bool \{ get }

Whether the call is on hold.

### localVideoStreams

@objc var localVideoStreams: \[[VILocalVideoStream](/api-reference/iossdk/calls/vilocalvideostream)] \{ get }

Array of the local video streams that are currently being sent.

This array can contain the local video stream instance before a call has been established, for example, before the remote side answers an outgoing call.

### remoteAudioStreams

@objc var remoteAudioStreams: \[[VIRemoteAudioStream](/api-reference/iossdk/calls/viremoteaudiostream)] \{ get }

Array of the remote audio streams that are currently being received.

### remoteVideoStreams

@objc var remoteVideoStreams: \[[VIRemoteVideoStream](/api-reference/iossdk/calls/viremotevideostream)] \{ get }

Array of the remote video streams that are currently being received.

### state

@objc var state: [VICallState](/api-reference/iossdk/calls/vicallstate) \{ get }

Call state.

### user

@objc var user: String? \{ get }

Call participant user name.

Not nil for incoming calls.

Nil for outgoing calls until `VICallDelegate/call(_:didConnectWithHeaders:)` is triggered.

### userDisplayName

@objc var userDisplayName: String? \{ get }

Call participant user display name.

Not nil for incoming calls.

Nil for outgoing calls until `VICallDelegate/call(_:didConnectWithHeaders:)` is triggered.

## Methods

### answer(with:)

@objc(answerWithSettings:) func answer(with settings: [VICallSettings](/api-reference/iossdk/calls/vicallsettings))

Answers an incoming call.

**Parameters**

**settings** [VICallSettings](/api-reference/iossdk/calls/vicallsettings)

Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. Any changes to the [VICallSettings](/api-reference/iossdk/calls/vicallsettings) object after calling this method have no effect.

It is possible to answer a call with video while the application is in the background. Video enables automatically when the application enters the foreground.

Does nothing if the method is called for an outgoing call.

Calling this method initiates the connection process. One of the following [VICallDelegate](/api-reference/iossdk/calls/vicalldelegate) events is triggered as a result:

* [call(\_:didConnectWithVideo:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-7ff005cb6c154788) is triggered when the call connects successfully.
* [call(\_:didFailWithError:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-a291f746b32b1239) is triggered if the call fails to connect.

### hangup(withHeaders:)

@objc func hangup(withHeaders headers: \[String : String]? = nil)

Terminates the call.

**Parameters**

**headers** \[String : String]?

Optional set of headers to send to the Voximplant Cloud. Names should begin with “X-” to be processed by the SDK.

Calling this method terminates the call. The following [VICallDelegate](/api-reference/iossdk/calls/vicalldelegate) events are triggered depending on the call state:

* [call(\_:didDisconnectWithReason:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-1ece00171ff67b73) is triggered on the local call instance.
* [call(\_:didDisconnectWithReason:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-1ece00171ff67b73) is triggered on the remote participant side if the call has connected.
* [call(\_:didDisconnectWithReason:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-1ece00171ff67b73) is triggered on the callee side if an outgoing call is still connecting.
* [call(\_:didFailWithError:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-a291f746b32b1239) is triggered on the caller side if an incoming call has not been answered.

### hold(\_:completion:)

@objc func hold(\_ hold: Bool, completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void)

Holds or unholds the call.

**Parameters**

**hold** Bool

Whether to hold or unhold the call

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

### muteAudio(\_:completion:)

@objc func muteAudio(\_ mute: Bool, completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void)

Mutes or unmutes the audio in the call.

**Parameters**

**mute** Bool

Whether the audio should be muted

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

### reject(with:headers:)

@objc(rejectWithMode:headers:) func reject(\
    with mode: [VIRejectMode](/api-reference/iossdk/calls/virejectmode),\
    headers: \[String : String]? = nil\
)

Rejects an incoming call.

**Parameters**

**mode** [VIRejectMode](/api-reference/iossdk/calls/virejectmode)

Call rejection mode

**headers** \[String : String]?

Optional set of headers to send to the Voximplant Cloud. Names should begin with “X-” to be processed by the SDK.

Does nothing if the method is called for an outgoing call.

Calling this method terminates the incoming call attempt. The following [VICallDelegate](/api-reference/iossdk/calls/vicalldelegate) events are triggered as a result:

* [call(\_:didDisconnectWithReason:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-1ece00171ff67b73) is triggered on the callee side.
* [call(\_:didFailWithError:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-a291f746b32b1239) is triggered on the caller side.

### replaceSendingVideo(with:completion:)

@objc func replaceSendingVideo(\
    with stream: [VILocalVideoStream](/api-reference/iossdk/calls/vilocalvideostream),\
    completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void\
)

Replaces the local video stream that is currently being sent to the call with another local video stream.

**Parameters**

**stream** [VILocalVideoStream](/api-reference/iossdk/calls/vilocalvideostream)

New local video stream

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

If the new local video stream has a different video source type, the other call participant receives the [call(\_:didChangeRemoteVideoStreamSource:)](/api-reference/iossdk/calls/vicalldelegate#symbol-587c4a8992c371dd) event.

### sendDTMF(\_:completion:)

@objc func sendDTMF(\_ dtmf: String, completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void)

Sends DTMF(s) within the call.

**Parameters**

**dtmf** String

DTMF(s)

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes the [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

### sendInfo(\_:mimeType:headers:)

@objc func sendInfo(\_ body: String, mimeType: String, headers: \[String : String]? = nil)

Sends an INFO message within the call.

**Parameters**

**body** String

Custom string data

**mimeType** String

MIME type of the info

**headers** \[String : String]?

Optional set of headers to be sent with the message. Names should begin with “X-” to be processed by the SDK. The default value is nil.

### sendMessage(\_:)

@objc func sendMessage(\_ message: String)

Sends a message within the call.

**Parameters**

**message** String

Message text

Implemented atop of SIP INFO for communication between the call endpoint and the Voximplant Cloud.

### start()

@objc func start()

Starts an outgoing call.

Does nothing if the method is called for an incoming call.

Calling this method initiates the call setup. The following [VICallDelegate](/api-reference/iossdk/calls/vicalldelegate) events may be triggered as a result:

* [call(\_:didStartRingingWithHeaders:)](/api-reference/iossdk/calls/vicalldelegate#symbol-34e868e1c43cc8dd) is triggered when the remote participant’s device starts ringing.
* [call(\_:didConnectWithVideo:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-7ff005cb6c154788) is triggered when the call connects successfully.
* [call(\_:didFailWithError:headers:)](/api-reference/iossdk/calls/vicalldelegate#symbol-a291f746b32b1239) is triggered if the call fails to connect, including when the callee rejects the call.

### startSendingVideo(with:completion:)

@objc func startSendingVideo(\
    with stream: [VILocalVideoStream](/api-reference/iossdk/calls/vilocalvideostream),\
    completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void\
)

Starts sending video to the call.

**Parameters**

**stream** [VILocalVideoStream](/api-reference/iossdk/calls/vilocalvideostream)

Local video stream

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

If the call starts as an audio call ([localVideoStream](/api-reference/iossdk/calls/vicallsettings#symbol-6fd7a38891511931) is `nil` and [receiveVideo](/api-reference/iossdk/calls/vicallsettings#symbol-45621f12c82c3938) is `false`), starting to send video also enables receiving video.

In an audio call, the SDK triggers the remote participant’s  [callUpgradeHandler](/api-reference/iossdk/calls/vicall#symbol-116c25a32daa1d14), if set, to accept or reject switching the call to video.

If the call already sends a video stream, use [replaceSendingVideo(with:completion:)](/api-reference/iossdk/calls/vicall#symbol-6f5bbae417fcf757) to replace the video without stopping the current video feed.

### stopSendingVideo(completion:)

@objc func stopSendingVideo(completion: @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void)

Stops sending video in the call.

**Parameters**

**completion** @escaping ([VICallError](/api-reference/iossdk/calls/vicallerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VICallError](/api-reference/iossdk/calls/vicallerror) object if the operation has failed.

## Relationships

**Inherits From:** NSObject

**Conforms To:** ObjectiveC.NSObjectProtocol, Swift.CVarArg, Swift.CustomDebugStringConvertible, Swift.CustomStringConvertible, Swift.Equatable, Swift.Hashable