VICall
VoximplantCalls · iOS SDK v3
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 instance creation.
For outgoing calls it is recommended to set CXStartCallAction.callUUID value to this property on handling CXStartCallAction
callUpgradeHandler
@objc var callUpgradeHandler: ((@escaping (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 object:
- accept() — enables receiving the remote video.
- acceptAndSend(localVideoStream:completion:) — enables receiving and start sending the provided local video stream.
- reject() — 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 is invoked.
If the call has already been upgraded to video, callUpgradeHandler is not invoked when the remote participant enables video again.
This handler is executed on the delegateQueue queue.
An audio call is one that is established with localVideoStream is nil and receiveVideo is false.
The handler is not invoked if video receiving enables automatically. For example, when localVideoStream is set but receiveVideo 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 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 is not set.
delegate
@objc weak var delegate: VICallDelegate?
Call delegate.
direction
@objc let direction: 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] { 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] { get }
Array of the remote audio streams that are currently being received.
remoteVideoStreams
@objc var remoteVideoStreams: [VIRemoteVideoStream] { get }
Array of the remote video streams that are currently being received.
state
@objc var state: 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)
Answers an incoming call.
Parameters
settings VICallSettings
Call settings with additional call parameters, such as the preferred video codec, custom data, extra headers, etc. Any changes to the 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 events is triggered as a result:
- call(_:didConnectWithVideo:headers:) is triggered when the call connects successfully.
- call(_:didFailWithError:headers:) 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 events are triggered depending on the call state:
- call(_:didDisconnectWithReason:headers:) is triggered on the local call instance.
- call(_:didDisconnectWithReason:headers:) is triggered on the remote participant side if the call has connected.
- call(_:didDisconnectWithReason:headers:) is triggered on the callee side if an outgoing call is still connecting.
- call(_:didFailWithError:headers:) is triggered on the caller side if an incoming call has not been answered.
hold(_:completion:)
@objc func hold(_ hold: Bool, completion: @escaping (VICallError?) -> Void)
Holds or unholds the call.
Parameters
hold Bool
Whether to hold or unhold the call
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a VICallError object if the operation has failed.
muteAudio(_:completion:)
@objc func muteAudio(_ mute: Bool, completion: @escaping (VICallError?) -> Void)
Mutes or unmutes the audio in the call.
Parameters
mute Bool
Whether the audio should be muted
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a VICallError object if the operation has failed.
reject(with:headers:)
@objc(rejectWithMode:headers:) func reject(
with mode: VIRejectMode,
headers: [String : String]? = nil
)
Rejects an incoming call.
Parameters
mode 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 events are triggered as a result:
- call(_:didDisconnectWithReason:headers:) is triggered on the callee side.
- call(_:didFailWithError:headers:) is triggered on the caller side.
replaceSendingVideo(with:completion:)
@objc func replaceSendingVideo(
with stream: VILocalVideoStream,
completion: @escaping (VICallError?) -> Void
)
Replaces the local video stream that is currently being sent to the call with another local video stream.
Parameters
stream VILocalVideoStream
New local video stream
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a 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:) event.
sendDTMF(_:completion:)
@objc func sendDTMF(_ dtmf: String, completion: @escaping (VICallError?) -> Void)
Sends DTMF(s) within the call.
Parameters
dtmf String
DTMF(s)
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes the 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 events may be triggered as a result:
- call(_:didStartRingingWithHeaders:) is triggered when the remote participant’s device starts ringing.
- call(_:didConnectWithVideo:headers:) is triggered when the call connects successfully.
- call(_:didFailWithError:headers:) is triggered if the call fails to connect, including when the callee rejects the call.
startSendingVideo(with:completion:)
@objc func startSendingVideo(
with stream: VILocalVideoStream,
completion: @escaping (VICallError?) -> Void
)
Starts sending video to the call.
Parameters
stream VILocalVideoStream
Local video stream
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a VICallError object if the operation has failed.
If the call starts as an audio call (localVideoStream is nil and receiveVideo is false), starting to send video also enables receiving video.
In an audio call, the SDK triggers the remote participant’s callUpgradeHandler, if set, to accept or reject switching the call to video.
If the call already sends a video stream, use replaceSendingVideo(with:completion:) to replace the video without stopping the current video feed.
stopSendingVideo(completion:)
@objc func stopSendingVideo(completion: @escaping (VICallError?) -> Void)
Stops sending video in the call.
Parameters
completion @escaping (VICallError?) -> Void
Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a 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