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.Parcelable
Represents 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.Creator
CREATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Call
accept(android.content.Context context, AcceptOptions acceptOptions, Call.Listener listener)
Call
accept(android.content.Context context, Call.Listener listener)
int
describeContents()
boolean
equals(java.lang.Object o)
CallerInfo
getCallerInfo()
Returns theCallerInfo
that provides caller verification information about the caller.java.lang.String
getCallSid()
Returns the CallSid.java.util.Map<java.lang.String,java.lang.String>
getCustomParameters()
Returns the custom parameters.java.lang.String
getFrom()
Returns the caller information when available.java.lang.String
getTo()
Returns the callee information.static boolean
isValid(android.content.Context context, android.os.Bundle data)
Validates whether the payload is a valid notification sent by Twilio.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.void
reject(android.content.Context context)
Rejects the incomingCallInvite
.void
writeToParcel(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 theCallerInfo
that provides caller verification information about the caller.
-
getCustomParameters
@NonNull public java.util.Map<java.lang.String,java.lang.String> getCustomParameters()
Returns the custom parameters.// 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 theCallInvite
with the providedAcceptOptions
and returns a newCall
. ASecurityException
will be thrown if RECORD_AUDIO is not granted.Call.Listener
receives the state of theCall
.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)
The call failed to connect. CallException
provides 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 CallException
is non-null. If the call ends normallyCallException
is null.3.0.0-preview1 If
accept
fails,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_FAILURE
20151 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.CONNECTING
3.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.DISCONNECTED
3.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 theCallInvite
with defaultAcceptOptions
and returns a newCall
. ASecurityException
will be thrown if RECORD_AUDIO is not granted.Call.Listener
receives the state of theCall
.Call.Listener events Callback Name Description Since version Call.Listener.onConnectFailure(Call, CallException)
The call failed to connect. CallException
provides 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 CallException
is non-null. If the call ends normallyCallException
is null.3.0.0-preview1 If
accept
fails,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_FAILURE
20151 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.CONNECTING
3.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.DISCONNECTED
3.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:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags)
- Specified by:
writeToParcel
in 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 aCallInvite
being 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 aCallInvite
being 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:
equals
in classjava.lang.Object
-
-