Class CallInvite
- java.lang.Object
-
- com.twilio.voice.CallInvite
-
- All Implemented Interfaces:
android.os.Parcelable
public class CallInvite extends java.lang.Object implements android.os.ParcelableRepresents an incoming call message from Twilio. This object is used to respond to an incoming call by callingaccept(Context, Call.Listener)orreject(Context)
-
-
Field Summary
Fields Modifier and Type Field Description static android.os.Parcelable.CreatorCREATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Callaccept(android.content.Context context, AcceptOptions acceptOptions, Call.Listener listener)Callaccept(android.content.Context context, Call.Listener listener)intdescribeContents()booleanequals(java.lang.Object o)CallerInfogetCallerInfo()Returns theCallerInfothat provides caller verification information about the caller.java.lang.StringgetCallSid()Returns the CallSid.java.util.Map<java.lang.String,java.lang.String>getCustomParameters()Returns the custom parameters.java.lang.StringgetFrom()Returns the caller information when available.java.lang.StringgetTo()Returns the callee information.static booleanisValid(android.content.Context context, android.os.Bundle data)Validates whether the payload is a valid notification sent by Twilio.static booleanisValid(android.content.Context context, java.util.Map<java.lang.String,java.lang.String> data)Validates whether the payload is a valid notification sent by Twilio.voidreject(android.content.Context context)Rejects the incomingCallInvite.voidwriteToParcel(android.os.Parcel dest, int flags)
-
-
-
Method Detail
-
getFrom
@Nullable public java.lang.String getFrom()
Returns the caller information when available.
-
getTo
@NonNull public java.lang.String getTo()
Returns the callee information.
-
getCallSid
@NonNull public java.lang.String getCallSid()
Returns the CallSid.
-
getCallerInfo
@NonNull public CallerInfo getCallerInfo()
Returns theCallerInfothat provides caller verification information about the caller.
-
getCustomParameters
@NonNull public java.util.Map<java.lang.String,java.lang.String> getCustomParameters()
Returns the custom parameters.
NOTE: While the value field passed into <Parameter> gets URI encoded by the Twilio infrastructure and URI decoded when parsed during the creation of a CallInvite, the name does not get URI encoded or decoded. As a result, it is recommended that the name field only use ASCII characters.// Pass custom parameters in TwiML <?xml version="1.0" encoding="UTF-8"?> <Response> <Dial answerOnBridge="false" callerId="client:alice"> <Client> <Identity>bob</Identity> <Parameter name="caller_first_name" value="alice" /> <Parameter name="caller_last_name" value="smith" /> </Client> </Dial> </Response>`callInvite.getCustomParameters()` returns a map of key-value pair passed in the TwiML."caller_first_name" -> "alice" "caller_last_name" -> "smith"
-
accept
@NonNull public Call accept(@NonNull android.content.Context context, @NonNull AcceptOptions acceptOptions, @NonNull Call.Listener listener)
Accepts theCallInvitewith the providedAcceptOptionsand returns a newCall. ASecurityExceptionwill be thrown if RECORD_AUDIO is not granted.Call.Listenerreceives the state of theCall.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)The call failed to connect. CallExceptionprovides details of the root cause.3.0.0-preview1 Call.Listener.onRinging(Call)This callback should not be invoked when calling accept(Context, AcceptOptions, Call.Listener)3.0.0-preview2 Call.Listener.onConnected(Call)The call has connected. 3.0.0-preview1 Call.Listener.onDisconnected(Call, CallException)The call was disconnected. If the call ends due to an error the CallExceptionis non-null. If the call ends normallyCallExceptionis null.3.0.0-preview1 If
acceptfails,Call.Listener.onConnectFailure(Call, CallException)callback is raised withCallException.VoiceException.getMessage()andVoiceException.getExplanation()provide details of the failure. IfCall.disconnect()is called while attempting to accept, theCall.Listener.onDisconnected(Call, CallException)callback will be raised with no error.If
accept(Context, AcceptOptions, Call.Listener)fails due to an authentication error, the SDK receives the following error.Authentication Exceptions Authentication Exception Error Code Description VoiceException.EXCEPTION_AUTH_FAILURE20151 Twilio failed to authenticate the client If
accept(Context, AcceptOptions, Call.Listener)fails due to any other reason, the SDK receives one of the following errors.Insights :
Insights events Group Name Event Name Description Since version connection accepted-by-local Call state remains Call.State.CONNECTING3.0.0-beta2 settings codec Negotiated selected codec is received and remote SDP is set 5.0.1 If accept fails, an error event is published to Insights.
Insights events Group Name Event Name Description Since version connection error Error description. Call state transitions to Call.State.DISCONNECTED3.0.0-beta2 - Parameters:
context- An Android context.acceptOptions- The options that configure the accepted call.listener- A listener that receives call status.- Returns:
- A new
Call- Usage example:
IceOptions iceOptions = new IceOptions.Builder() .iceTransportPolicy(IceTransportPolicy.RELAY) .build(); AcceptOptions acceptOptions = new AcceptOptions.Builder() .iceOptions(iceOptions) .build(); Call call = callInvite.accept(context, acceptOptions, new Call.Listener() { @Override public void onRinging(@NonNull Call call) { // This callback will not be invoked when accepting a call invite } @Override public void onConnected(@NonNull final Call call) { Log.d(TAG, "Received onConnected " + call.getSid()); } @Override public void onConnectFailure(@NonNull Call call, @NonNull CallException callException) { Log.d(TAG, "Received onConnectFailure with CallException: " + callException.getErrorCode()+ ":" + callException.getMessage()); } @Override public void onDisconnected(@NonNull Call call, CallException callException) { if (callException != null) { Log.d(TAG, "Received onDisconnected with CallException: " + callException.getMessage() + ": " + call.getSid()); } else { Log.d(TAG, "Received onDisconnected"); } } }); }
-
accept
@NonNull public Call accept(@NonNull android.content.Context context, @NonNull Call.Listener listener)
Accepts theCallInvitewith defaultAcceptOptionsand returns a newCall. ASecurityExceptionwill be thrown if RECORD_AUDIO is not granted.Call.Listenerreceives the state of theCall.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)The call failed to connect. CallExceptionprovides details of the root cause.3.0.0-preview1 Call.Listener.onRinging(Call)This callback should not be invoked when calling accept(Context, Call.Listener)3.0.0-preview2 Call.Listener.onConnected(Call)The call has connected. 3.0.0-preview1 Call.Listener.onDisconnected(Call, CallException)The call was disconnected. If the call ends due to an error the CallExceptionis non-null. If the call ends normallyCallExceptionis null.3.0.0-preview1 If
acceptfails,Call.Listener.onConnectFailure(Call, CallException)callback is raised withCallException.VoiceException.getMessage()andVoiceException.getExplanation()provide details of the failure. IfCall.disconnect()is called while attempting to accept, theCall.Listener.onDisconnected(Call, CallException)callback will be raised with no error.If
accept(Context, Call.Listener)fails due to an authentication error, the SDK receives the following error.Authentication Exceptions Authentication Exception Error Code Description VoiceException.EXCEPTION_AUTH_FAILURE20151 Twilio failed to authenticate the client If
accept(Context, Call.Listener)fails due to any other reason, the SDK receives one of the following errors.Insights :
Insights events Group Name Event Name Description Since version connection accepted-by-local Call state remains Call.State.CONNECTING3.0.0-beta2 settings codec Negotiated selected codec is received and remote SDP is set 5.0.1 If accept fails, an error event is published to Insights.
Insights events Group Name Event Name Description Since version connection error Error description. Call state transitions to Call.State.DISCONNECTED3.0.0-beta2 - Parameters:
context- An Android context.listener- A listener that receives call status.- Returns:
- A new
Call- Usage example:
Call call = callInvite.accept(context, new Call.Listener() { @Override public void onRinging(@NonNull Call call) { // This callback will not be invoked when accepting a call invite } @Override public void onConnected(@NonNull final Call call) { Log.d(TAG, "Received onConnected " + call.getSid()); } @Override public void onConnectFailure(@NonNull Call call, @NonNull CallException callException) { Log.d(TAG, "Received onConnectFailure with CallException: " + callException.getErrorCode()+ ":" + callException.getMessage()); } @Override public void onDisconnected(@NonNull Call call, CallException callException) { if (callException != null) { Log.d(TAG, "Received onDisconnected with CallException: " + callException.getMessage() + ": " + call.getSid()); } else { Log.d(TAG, "Received onDisconnected"); } } }); }
-
reject
public void reject(@NonNull android.content.Context context)Rejects the incomingCallInvite.Insights :
Insights events Group Name Event Name Description Since version connection rejected-by-local Call invite is rejected 3.0.0-beta2 connection error The event will be sent with code 31600 and message "Busy Everywhere : SIP/2.0 600 Call Rejected" 3.1.0
-
describeContents
public int describeContents()
- Specified by:
describeContentsin interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags)- Specified by:
writeToParcelin interfaceandroid.os.Parcelable
-
isValid
public static boolean isValid(android.content.Context context, android.os.Bundle data)Validates whether the payload is a valid notification sent by Twilio. A valid notification payload will result in aCallInvitebeing raised viaMessageListener.onCallInvite(CallInvite)callback when passed toVoice.handleMessage(...).- Parameters:
context- An Android context.data- Push notification payload.- Returns:
- A boolean value that indicates whether the payload is a valid notification sent by Twilio.
-
isValid
public static boolean isValid(android.content.Context context, java.util.Map<java.lang.String,java.lang.String> data)Validates whether the payload is a valid notification sent by Twilio. A valid notification payload will result in aCallInvitebeing raised viaMessageListener.onCallInvite(CallInvite)callback when passed toVoice.handleMessage(...).- Parameters:
context- An Android context.data- Push notification payload.- Returns:
- A boolean value that indicates whether the payload is a valid notification sent by Twilio.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-