public class CallInvite extends Object implements android.os.Parcelable
accept(Context, Call.Listener)
or
reject(Context)
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator |
CREATOR |
Modifier and Type | Method and 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(Object o) |
String |
getCallSid()
Returns the CallSid.
|
Map<String,String> |
getCustomParameters()
Returns the custom parameters.
|
String |
getFrom()
Returns the caller information when available.
|
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,
Map<String,String> data)
Validates whether the payload is a valid notification sent by Twilio.
|
void |
reject(android.content.Context context)
Rejects the incoming
CallInvite . |
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public String getFrom()
public String getTo()
public String getCallSid()
public Map<String,String> getCustomParameters()
NOTE: While the value field passed into// 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"
public Call accept(android.content.Context context, AcceptOptions acceptOptions, Call.Listener listener)
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
.
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 normally CallException is null. | 3.0.0-preview1 |
If accept
fails, Call.Listener.onConnectFailure(Call, CallException)
callback is raised with CallException
. VoiceException.getMessage()
and VoiceException.getExplanation()
provide details of the failure.
If Call.disconnect()
is called while attempting to accept, the Call.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 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 :
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.
Group Name | Event Name | Description | Since version |
connection | error | Error description. Call state transitions to Call.State.DISCONNECTED | 3.0.0-beta2 |
context
- An Android context.acceptOptions
- The options that configure the accepted call.listener
- A listener that receives call status.Call
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");
}
}
});
}
public Call accept(android.content.Context context, Call.Listener listener)
CallInvite
with default 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
.
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 normally CallException is null. | 3.0.0-preview1 |
If accept
fails, Call.Listener.onConnectFailure(Call, CallException)
callback is raised with CallException
. VoiceException.getMessage()
and VoiceException.getExplanation()
provide details of the failure.
If Call.disconnect()
is called while attempting to accept, the Call.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 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 :
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.
Group Name | Event Name | Description | Since version |
connection | error | Error description. Call state transitions to Call.State.DISCONNECTED | 3.0.0-beta2 |
context
- An Android context.listener
- A listener that receives call status.Call
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");
}
}
});
}
public void reject(android.content.Context context)
CallInvite
.
Insights :
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 |
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public static boolean isValid(android.content.Context context, android.os.Bundle data)
CallInvite
being raised via MessageListener.onCallInvite(CallInvite)
callback when passed to Voice.handleMessage(...)
.context
- An Android context.data
- Push notification payload.public static boolean isValid(android.content.Context context, Map<String,String> data)
CallInvite
being raised via MessageListener.onCallInvite(CallInvite)
callback when passed to Voice.handleMessage(...)
.context
- An Android context.data
- Push notification payload.5.2.0