-
- All Implemented Interfaces:
-
android.os.Parcelable
public class CallInvite implements Parcelable
Represents an incoming call message from Twilio. This object is used to respond to an incoming call by calling accept or
-
-
Field Summary
Fields Modifier and Type Field Description private final StringcallSidprivate final Stringfromprivate final Stringtoprivate CallerInfocallerInfofinal Map<String, String>customParameterspublic final static Parcelable.CreatorCREATOR
-
Method Summary
Modifier and Type Method Description StringgetCallSid()Returns the CallSid. StringgetFrom()Returns the caller information when available. StringgetTo()Returns the callee information. CallerInfogetCallerInfo()Returns the CallerInfo that provides caller verification information about thecaller. Map<String, String>getCustomParameters()Returns the custom parameters. synchronized Callaccept(@NonNull() Context context, @NonNull() AcceptOptions acceptOptions, @NonNull() Call.Listener listener)Accepts the CallInvite with the provided AcceptOptions and returns a new Call. synchronized Callaccept(@NonNull() Context context, @NonNull() Call.Listener listener)Accepts the CallInvite with default AcceptOptions and returns a new . synchronized voidreject(@NonNull() Context context)Rejects the incoming CallInvite. intdescribeContents()voidwriteToParcel(Parcel dest, int flags)StringsendMessage(CallMessage message)Sends a user-defined message to endpoints that have subscribed for user-defined messages. static booleanisValid(Context context, Bundle data)Validates whether the payload is a valid notification sent by Twilio. static booleanisValid(Context context, Map<String, String> data)Validates whether the payload is a valid notification sent by Twilio. booleanequals(Object o)-
-
Method Detail
-
getCallSid
@NonNull() String getCallSid()
Returns the CallSid.
-
getCallerInfo
@NonNull() CallerInfo getCallerInfo()
Returns the CallerInfo that provides caller verification information about thecaller.
-
getCustomParameters
@NonNull() Map<String, String> getCustomParameters()
Returns the custom parameters.
NOTE: While the value field passed into <Parameter> gets URI encoded by the Twilioinfrastructure and URI decoded when parsed during the creation of a CallInvite, the name doesnot get URI encoded or decoded. As a result, it is recommended that the name field only useASCII characters.{@code * // Pass custom parameters in TwiML * * * * * }`callInvite.getCustomParameters()` returns a map of key-value pair passed in the TwiML.{@code * "caller_first_name" -> "alice" * "caller_last_name" -> "smith" * }
-
accept
@NonNull() synchronized Call accept(@NonNull() Context context, @NonNull() AcceptOptions acceptOptions, @NonNull() Call.Listener listener)
Accepts the CallInvite with the provided AcceptOptions and returns a new Call. A SecurityException will be thrown if RECORD_AUDIO is not granted.
Call.Listener receives the state of the Call.
If
{@code accept}fails, onConnectFailure callback is raised with CallException. getMessage and provide details of the failure.If disconnect is called while attempting to accept, the callback will be raised with no error.
If accept fails due to anauthentication error, the SDK receives the following error.
If accept fails due to any otherreason, the SDK receives one of the following errors.
Insights :
If accept fails, an error event is published to Insights.
- Parameters:
context- An Android context.acceptOptions- The options that configure the accepted call.listener- A listener that receives call status.
-
accept
@NonNull() synchronized Call accept(@NonNull() Context context, @NonNull() Call.Listener listener)
Accepts the CallInvite with default AcceptOptions and returns a new . A SecurityException will be thrown if RECORD_AUDIO is not granted.
Call.Listener receives the state of the Call.
If
{@code accept}fails, onConnectFailure callback is raised with CallException. getMessage and provide details of the failure.If disconnect is called while attempting to accept, the callback will be raised with no error.
If accept fails due to an authentication error,the SDK receives the following error.
If accept fails due to any other reason, theSDK receives one of the following errors.
Insights :
If accept fails, an error event is published to Insights.
- Parameters:
context- An Android context.listener- A listener that receives call status.
-
reject
synchronized void reject(@NonNull() Context context)
Rejects the incoming CallInvite.
Insights :
-
describeContents
int describeContents()
-
writeToParcel
void writeToParcel(Parcel dest, int flags)
-
sendMessage
String sendMessage(CallMessage message)
Sends a user-defined message to endpoints that have subscribed for user-defined messages. Theresult will be raised to the Call.CallMessageListener provided as either a callbackargument to the handleMessage method and/or asan accept option when a call invite is either accepted or rejected. Calling the `sendMessage`method without subscribing first will result in an error in your Twilio developer console.Sending a call message with content size that exceeds 10 KB or sending more than 10 callmessages within one minute will result in the callback. Whenattempting to send a message larger than 10k, the error will not show in the developerconsole. A call message with content that does not match the content type will not result inthe onMessageFailure callback but will generate an error in your Twilio developer console. For example, a callmessage with content type "application/json" but with the content "Hello World", which is nota valid JSON object, will result in such error.
- Parameters:
message- The call message to send.
-
isValid
static boolean isValid(Context context, Bundle data)
Validates whether the payload is a valid notification sent by Twilio. A valid notificationpayload will result in a CallInvite being raised via callback when passed to
{@code * Voice.handleMessage(...)}.- Parameters:
context- An Android context.data- Push notification payload.
-
isValid
static boolean isValid(Context context, Map<String, String> data)
Validates whether the payload is a valid notification sent by Twilio. A valid notificationpayload will result in a CallInvite being raised via callback when passed to
{@code * Voice.handleMessage(...)}.- Parameters:
context- An Android context.data- Push notification payload.
-
-
-
-