TVOCallInvite
Objective-C
@interface TVOCallInvite : NSObject
Swift
class TVOCallInvite : NSObject
The TVOCallInvite object represents an incoming Call Invite. TVOCallInvites are not created directly;
they are returned by the <[TVONotificationDelegate callInviteReceived:]> delegate method.
-
@brief
Fromvalue of the Call Invite.@discussion This may be
nilif the notification passed in<[TwilioVoiceSDK handleNotification:delegate:delegateQueue:callMessageDelegate:]>method does not have valid information in it.Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *from;Swift
var from: String? { get } -
@brief
Tovalue of the Call Invite.Declaration
Objective-C
@property (nonatomic, copy, readonly, nonnull) NSString *to;Swift
var to: String { get } -
@brief A server assigned identifier (SID) for the incoming Call.
@discussion Accepting a
TVOCallInviteyields aTVOCallwhich inherits this SID.See
TVOCall.sidDeclaration
Objective-C
@property (nonatomic, copy, readonly, nonnull) NSString *callSid;Swift
var callSid: String { get } -
@brief Custom parameters embedded in the VoIP notification payload.
@discussion The custom parameters will be received in the notification payload with the
twi_paramskey and in query-string format, e.g.key1=value1&key2=value2. To receive custom parameters on the mobile client, add<Parameter>tags into the<Client>tag in the TwiML response.<?xml version="1.0" encoding="UTF-8"?> <Response> <Dial callerId="client:alice"> <Client> <Identity>bob</Identity> <Parameter name="caller_first_name" value="alice" /> <Parameter name="caller_last_name" value="smith" /> </Client> </Dial> </Response>The
customParametersvalue would be:{ "caller_first_name" = "alice"; "caller_last_name" = "smith"; }Note: While the value field passed into
<Parameter>gets URI encoded by the Twilio infrastructure and URI decoded when parsed during the creation of aTVOCallInvite, the name does not get URI encoded or decoded. As a result, it is recommended that the name field only use ASCII characters.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) NSDictionary<NSString *, NSString *> *customParameters;Swift
var customParameters: [String : String]? { get } -
@brief The
TVOCallerInfothat represents SHAKEN/STIR status information about the caller.See
TVOCallerInfo.Declaration
Objective-C
@property (nonatomic, strong, readonly, nonnull) TVOCallerInfo *callerInfo;Swift
var callerInfo: TVOCallerInfo { get }
-
@brief Accepts the incoming Call Invite.
@discussion This method is guaranteed to return a
<TVOCall>object. It’s possible for the returned Call to either succeed or fail to connect.The
<TVOCallDelegate>will receive the Call state update callbacks. The callbacks are listed here.Callback Name Description Since version call:didFailToConnectWithError The call failed to connect. An `NSError` object provides details of the root cause. 3.0.0-preview1 callDidStartRinging: This callback should not be invoked when calling `<[TVOCallInvite acceptWithDelegate:]>`. 3.0.0-preview2 callDidConnect: The Call has connected. 3.0.0-preview1 call:didDisconnectWithError The Call was disconnected. If the Call ends due to an error the `NSError` is non-null. If the call ends normally `NSError` is nil. 3.0.0-preview1 If accept fails,
call:didFailToConnectWithError:orcall:didDisconnectWithError:callback is raised with anNSErrorobject.[error localizedDescription],[error localizedFailureReason]and[error code]provide details of the failure.If
<[TVOCallInvite acceptWithDelegate:]>fails due to an authentication error, the SDK receives the following error.Authentication Errors Error Code Description TVOErrorAuthFailureCodeError 20151 Twilio failed to authenticate the client If any connection fails because of any other error then the SDK will receive one of the following errors.
Connection Errors Error Code Description TVOErrorConnectionError 31005 Connection error TVOErrorCallCancelledError 31008 Call Cancelled TVOErrorTransportError 31009 Transport error TVOErrorAuthorizationError 31201 Authorization error TVOErrorForbiddenError 31403 Forbidden TVOErrorRequestTimeoutError 31408 Request Timeout TVOErrorCallDoesNotExistError 31481 Call/Transaction Does Not Exist TVOErrorRequestTerminatedError 31487 Request Terminated TVOErrorInternalServerError 31500 Internal Server Error TVOErrorBadGatewayError 31502 Bad Gateway TVOErrorServiceUnavailableError 31503 Service Unavailable TVOErrorGatewayTimeoutError 31504 Gateway Timeout TVOErrorDNSResolutionError 31530 DNS Resolution Error TVOErrorDoesNotExistAnywhereError 31604 Does Not Exist Anywhere TVOErrorSignalingConnectionDisconnectedError 53001 Signaling connection disconnected TVOErrorMediaClientLocalDescFailedError 53400 Client is unable to create or apply a local media description TVOErrorMediaServerLocalDescFailedError 53401 Server is unable to create or apply a local media description TVOErrorMediaClientRemoteDescFailedError 53402 Client is unable to apply a remote media description TVOErrorMediaServerRemoteDescFailedError 53403 Server is unable to apply a remote media description TVOErrorMediaNoSupportedCodecError 53404 No supported codec TVOErrorMediaConnectionError 53405 Media connection failed TVOMediaDtlsTransportFailedErrorCode 53407 Media connection failed due to DTLS handshake failure Insights
Group Name Event Name Description Since version connection accepted-by-local Call invite accepted 3.0.0-beta2 settings codec negotiated selected codec is received and remote SDP is set 5.1.1 If connection fails then an error event will be published.
Group Name Event Name Description Since version connection error error description 3.0.0-beta2 ** An example of using the acceptWithDelegate: API **
@interface CallViewController () <TVOCallDelegate, TVONotificationDelegate, ... > // property declarations @end @implementation CallViewController // ViewController setup and other code ... - (void)callInviteReceived:(TVOCallInvite *)callInvite { self.call = [callInvite acceptWithDelegate:self]; } #pragma mark - TVOCallDelegate - (void)call:(TVOCall *)call didFailToConnectWithError:(NSError *)error { NSLog("Failed to Connect the Call: %@\n\t - reason: %@", [error localizedDescription], [error localizedFailureReason]); } - (void)call:(TVOCall *)call didDisconnectWithError:(NSError *)error { if (error) { NSLog(@"Call disconnected with error: %@", error); } else { NSLog(@"Call disconnected"); } } - (void)callDidConnect:(TVOCall *)call { NSLog(@"Call connected."); } @endSee
TVOCallDelegate
Declaration
Objective-C
- (nonnull TVOCall *)acceptWithDelegate:(nonnull id<TVOCallDelegate>)delegate;Swift
func accept(with delegate: any TVOCallDelegate) -> TVOCallParameters
delegateA
<TVOCallDelegate>to receive Call state updates.Return Value
A
TVOCallobject. -
@brief Accepts the incoming Call Invite.
@discussion This method is guaranteed to return a
<TVOCall>object. It’s possible for the returned Call to either succeed or fail to connect.The
<TVOCallDelegate>will receive the Call state update callbacks. The callbacks are same asacceptWithDelegate:API.If accept fails,
call:didFailToConnectWithError:orcall:didDisconnectWithError:callback is raised with anNSErrorobject.[error localizedDescription],[error localizedFailureReason]and[error code]provide details of the failure. The error codes are same asacceptWithDelegate:API.Insights
Group Name Event Name Description Since version connection accepted-by-local Call invite accepted 3.0.0-beta2 If connection fails then an error event will be published.
Group Name Event Name Description Since version connection error error description 3.0.0-beta2 ** An example of using the acceptWithOptions:delegate: API **
@interface CallViewController () <TVOCallDelegate, TVONotificationDelegate, ... > // property declarations @end @implementation CallViewController // ViewController setup and other code ... - (void)callInviteReceived:(TVOCallInvite *)callInvite { TVOAcceptOptions *options = [TVOAcceptOptions optionsWithCallInvite:callInvite block:^(TVOAcceptOptionsBuilder *builder) { builder.uuid = callInvite.uuid; }]; self.call = [callInvite acceptWithOptions:options delegate:self]; } #pragma mark - TVOCallDelegate - (void)call:(TVOCall *)call didFailToConnectWithError:(NSError *)error { NSLog("Failed to Connect the Call: %@\n\t - reason: %@", [error localizedDescription], [error localizedFailureReason]); } - (void)call:(TVOCall *)call didDisconnectWithError:(NSError *)error { if (error) { NSLog(@"Call disconnected with error: %@", error); } else { NSLog(@"Call disconnected"); } } - (void)callDidConnect:(TVOCall *)call { NSLog(@"Call connected."); } @endSee
TVOAcceptOptions
See
TVOCallDelegate
Declaration
Objective-C
- (nonnull TVOCall *)acceptWithOptions:(nonnull TVOAcceptOptions *)options delegate:(nonnull id<TVOCallDelegate>)delegate;Swift
func accept(with options: TVOAcceptOptions, delegate: any TVOCallDelegate) -> TVOCallParameters
optionsAn accept options.
delegateA
<TVOCallDelegate>to receive Call state updates.Return Value
A
TVOCallobject. -
@brief Rejects the incoming Call Invite.
Insights
Group Name Event Name Description Since version connection rejected-by-local Call invite rejected 3.0.0-preview5 connection error The event will be sent with code 31600 and message “Busy Everywhere : SIP/2.0 600 Call Rejected” 3.1.0 Declaration
Objective-C
- (void)reject;Swift
func reject() -
@brief Sends a user-defined message to the endpoints that subscribe to the user-defined messages of this Call Invite.
@discussion The result will be raised to the
TVOCallMessageDelegateprovided in the[TwilioVoiceSDK handleNotification:delegate:delegateQueue:callMessageDelegate:]on the same dispatch queue. Dispatch main queue will be used if not specified.@discussion Sending a call message with content size that exceeds 10 KB or sending more than 10 call messages within one minute will result in the
[TVOCallMessageDelegate call:didFailToSendMessage:error]callback.@discussion A call message with content that does not match the content type will not result in the
[TVOCallMessageDelegate call:didFailToSendMessage:error]callback but will generate an error in your Twilio developer console. For example, a call message with content type “application/json” but with the content “Hello World”, which is not a valid JSON object, will result in such error.@discussion A subscription with a user-defined message callback is required prior to calling this method. Calling the
[TVOCallInvite sendMessage:]method without subscribing first will result in an error in your Twilio developer console.@discussion This method returns an empty string and will not send out the Call Message if the Call Invite has been accepted or rejected.
@discussion This feature is currently in Beta.
Declaration
Objective-C
- (nonnull NSString *)sendMessage:(nonnull TVOCallMessage *)callMessage;Swift
func send(_ callMessage: TVOCallMessage) -> StringParameters
callMessageThe
TVOCallMessageobject with the message and configuration.Return Value
A unique identifier for tracking the message.
-
Unavailable
Call Invites cannot be instantiated directly. See
TVONotificationDelegate@brief Call Invites cannot be instantiated directly. See
<TVONotificationDelegate>instead.See
TVONotificationDelegateDeclaration
Objective-C
- (null_unspecified instancetype)init;
-
@brief UUID of the Call Invite.
@discussion Use this UUID for CallKit methods. Accepting a
TVOCallInviteyields aTVOCallwhich inherits its UUID from the Invite.Declaration
Objective-C
@property (nonatomic, copy, readonly, nonnull) NSUUID *uuid;Swift
var uuid: UUID { get }
-
@brief Returns
trueif the provided payload would result in aTVOCallInvitevia the[TVONotificationDelegate callInviteReceived:]callback when passed into[TwilioVoiceSDK handleNotification:delegate:delegateQueue:callMessageDelegate:].Declaration
Objective-C
+ (BOOL)isValid:(nonnull NSDictionary *)payload;Swift
class func isValid(_ payload: [AnyHashable : Any]) -> BoolParameters
payloadPush notification payload.