-
public abstract class Voice
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumVoice.RegistrationChannel
-
Field Summary
Fields Modifier and Type Field Description static Map<LogModule, LogLevel>moduleLogLevelstatic LoggerInterfaceloggerstatic Stringregionstatic Stringedgestatic AudioDeviceaudioDevice
-
Method Summary
Modifier and Type Method Description static LogLevelgetModuleLogLevel(LogModule module)Returns the logging level for messages logged by the specified LogModule. static synchronized LoggerInterfacegetLogger()Returns the logger object that was previously set using setLogger.If no custom logger was set, this method returns the default logger currently used by theSDK. static synchronized voidsetLogger(@NonNull() LoggerInterface logger)Sets the logger to which all log messages will be delivered. static StringgetRegion()Returns the region specified region. static voidsetRegion(@NonNull() String region)Sets the region (Twilio data center) for the SDK. static StringgetEdge()Returns the edge specified by edge. static voidsetEdge(@NonNull() String edge)Sets the edge (Twilio data center) for the SDK. static AudioDevicegetAudioDevice()Returns the AudioDevice. static voidsetAudioDevice(@NonNull() AudioDevice audioDevice)Sets the custom audio device. static voidregister(@NonNull() String accessToken, @NonNull() Voice.RegistrationChannel registrationChannel, @NonNull() String registrationToken, @NonNull() RegistrationListener listener)Register for incoming call messages. static voidunregister(@NonNull() String accessToken, @NonNull() Voice.RegistrationChannel registrationChannel, @NonNull() String registrationToken, @NonNull() UnregistrationListener listener)Unregister from receiving further incoming call messages. static Callconnect(@NonNull() Context context, @NonNull() ConnectOptions connectOptions, @NonNull() Call.Listener listener)Creates and returns a new Call. static Callconnect(@NonNull() Context context, @NonNull() String accessToken, @NonNull() Call.Listener listener)Creates and returns a new Call. static synchronized booleanhandleMessage(@NonNull() Context context, @NonNull() Map<String, String> data, @NonNull() MessageListener listener)Handle messages from FCM. static synchronized booleanhandleMessage(@NonNull() Context context, @NonNull() Map<String, String> data, @NonNull() MessageListener listener, Call.CallMessageListener callMessageListener)Handle messages from FCM. static booleanhandleMessage(@NonNull() Context context, @NonNull() Bundle data, @NonNull() MessageListener listener)Handle messages from GCM. static booleanhandleMessage(@NonNull() Context context, @NonNull() Bundle data, @NonNull() MessageListener listener, Call.CallMessageListener callMessageListener)Handle messages from GCM. static StringgetVersion()Returns the version of the Voice SDK. static LogLevelgetLogLevel()Returns the logging level for messages logged by the Voice SDK. static booleanisInsightsEnabled()Returns if reporting statistics to Insights is enabled. static voidsetLogLevel(@NonNull() LogLevel level)Sets the logging level for messages logged by the Voice SDK. static voidenableInsights(boolean enable)Specify reporting statistics to Insights. -
-
Method Detail
-
getModuleLogLevel
@NonNull() static LogLevel getModuleLogLevel(LogModule module)
Returns the logging level for messages logged by the specified LogModule. The default loglevel for each module is ERROR.
-
getLogger
@NonNull() static synchronized LoggerInterface getLogger()
Returns the logger object that was previously set using setLogger.If no custom logger was set, this method returns the default logger currently used by theSDK.
-
setLogger
static synchronized void setLogger(@NonNull() LoggerInterface logger)
Sets the logger to which all log messages will be delivered.
- Parameters:
logger- An object that implements the LoggerInterface interface.
-
getRegion
@Deprecated()@NonNull() static String getRegion()
-
setRegion
@Deprecated() static void setRegion(@NonNull() String region)
Sets the region (Twilio data center) for the SDK.
The default region uses Global Low Latency routing, which establishes a connection withthe closest region to the user.
NOTE: Setting the region during a call will not be applied to ongoing calls. The regionwill be applied to subsequent connect or API calls.
- Parameters:
region- The region.
-
setEdge
static void setEdge(@NonNull() String edge)
Sets the edge (Twilio data center) for the SDK.
The edge value is a Twilio Edge name that corresponds to a geographic location of Twilioinfrastructure that the client will connect to. The default value `roaming` automaticallyselects an edge based on the latency between client and available edges. `roaming` requiresthe upstream DNS to support [RFC7871](https://tools.ietf.org/html/rfc7871). See [Global LowLatencyrequirements](https://www.twilio.com/docs/voice/client/javascript/voice-client-js-and-mobile-sdks-network-connectivity-requirements#global-low-latency-requirements)for more information.
NOTE: Setting the edge during a call will not be applied to ongoing calls. The edge willbe applied to subsequent connect or API calls.
The SDK will throw the IllegalArgumentException if both edge and`region` values are specified.
- Parameters:
edge- The edge.
-
getAudioDevice
@NonNull() static AudioDevice getAudioDevice()
Returns the AudioDevice.
-
setAudioDevice
static void setAudioDevice(@NonNull() AudioDevice audioDevice)
Sets the custom audio device. The audioDevice can be updated when there is nocall in progress and will be applied to subsequent connect or handleMessage API calls.Setting the audioDevice during a call will result in .
- Parameters:
audioDevice- The audio device.
-
register
static void register(@NonNull() String accessToken, @NonNull() Voice.RegistrationChannel registrationChannel, @NonNull() String registrationToken, @NonNull() RegistrationListener listener)
Register for incoming call messages. A successful registration will ensure that pushnotifications will arrive via the FCM service for the lifetime of the registration devicetoken provided by the FCM service instance. When registration is successful,
{@code * RegistrationListener.onRegistered(...)}callback is raised. Once successfully registered, theregistered binding has a time-to-live(TTL) of 1 year. If the registered binding is inactivefor 1 year, it is deleted and push notifications to the registered identity will not succeed.However, whenever the registered binding is used to reach the registered identity, the TTL isreset to 1 year.If registration fails,
{@code RegistrationListener.onError(...)}callback is raised with{@code RegistrationException}.{@code RegistrationException.getMessage(...)}provides theroot cause of the failure.The identity provided in the
{@code accessToken}may only contain alpha-numeric andunderscore characters. Other characters, including spaces, will result in undefined behavior.Insights :The maximum number of characters for the identity provided in the token is 121. Theidentity may only contain alpha-numeric and underscore characters. Other characters,including spaces, or exceeding the maximum number of characters, will result in not beingable to place or receive calls.
- Parameters:
accessToken- An access token.registrationChannel- An enumeration of registration channels.registrationToken- A GCM or FCM registration token.listener- A listener that receives registration request status.
-
unregister
static void unregister(@NonNull() String accessToken, @NonNull() Voice.RegistrationChannel registrationChannel, @NonNull() String registrationToken, @NonNull() UnregistrationListener listener)
Unregister from receiving further incoming call messages. When unregistration is successful,
{@code UnregistrationListener.onUnregistered(...)}callback is raised.If unregistration fails,
{@code UnregistrationListener.onError(...)}callback is raisedwith{@code RegistrationException}.{@code RegistrationException.getMessage(...)}providesthe root cause of the failure.The identity provided in the
{@code accessToken}may only contain alpha-numeric andunderscore characters. Other characters, including spaces, will result in undefined behavior.Insights :The maximum number of characters for the identity provided in the token is 121. Theidentity may only contain alpha-numeric and underscore characters. Other characters,including spaces, or exceeding the maximum number of characters, will result in not beingable to place or receive calls.
- Parameters:
accessToken- An access token.registrationChannel- An enumeration of registration channels.registrationToken- An FCM or GCM device token.listener- A listener that receives unregistration request status.
-
connect
@NonNull() static Call connect(@NonNull() Context context, @NonNull() ConnectOptions connectOptions, @NonNull() Call.Listener listener)
Creates and returns a new Call. A SecurityException will be thrown ifRECORD_AUDIO is not granted.
Call.Listener receives the state of the Call.
If
{@code connect}fails, onConnectFailure callback is raised with CallException. getMessage and provide details of the failure.If disconnect is called while attempting to connect, the callback will be raised with no error.
If connect fails due to anauthentication error, the SDK receives one of the following errors.
If connect fails due to any otherreasons, the SDK receives one of the following errors.
Insights :
If connect fails, an error event is published to Insights.
- Parameters:
context- An Android context.connectOptions- A set of options that allow you to configure your Call.listener- A listener that receives call status.
-
connect
@NonNull() static Call connect(@NonNull() Context context, @NonNull() String accessToken, @NonNull() Call.Listener listener)
Creates and returns a new Call. A SecurityException will be thrown ifRECORD_AUDIO is not granted.
Call.Listener receives the state of the Call.
If
{@code connect}fails, onConnectFailure callback is raised with CallException. getMessage and provide details of the failure.If disconnect is called while attempting to connect, the callback will be raised with no error.
If connect fails due to an authenticationerror, the SDK receives one of the following errors.
If connect fails due to any other reason,the SDK receives one of the following errors.
The identity provided in the
{@code accessToken}may only contain alpha-numeric andunderscore characters. Other characters, including spaces, will result in undefined behavior.Insights :
If connect fails, an error event is published to Insights.
The maximum number of characters for the identity provided in the token is 121. Theidentity may only contain alpha-numeric and underscore characters. Other characters,including spaces, or exceeding the maximum number of characters, will result in not beingable to place or receive calls.
- Parameters:
context- An Android context.accessToken- The accessToken that provides the identity and grants of the caller.listener- A listener that receives call status.
-
handleMessage
static synchronized boolean handleMessage(@NonNull() Context context, @NonNull() Map<String, String> data, @NonNull() MessageListener listener)
Handle messages from FCM.
Twilio sends
{@code call}notification messages via GCM/FCM. The message type is encodedin the dictionary with the key{@code twi_message_type}with the value{@code * twilio.voice.call}.A
{@code call}message is sent when someone wants to reach the registered{@code * identity}. Passing a{@code call}message into handleMessage will result in a CallInvite raised in the MessageListener and return{@code true}.A CancelledCallInvite will be raised to the provided MessageListener forthe following reasons:
- The call is prematurely disconnected by the caller
- The callee does not accept or reject the call within 30 seconds
- The SDK is unable to establish a connection to Twilio
Passing malformed data to handleMessage willreturn
{@code false}and no MessageListener callback will be raised.Insights :
- Parameters:
context- An Android context.data- Push notification payload.listener- A MessageListener to receive incoming push notification callbacks.
-
handleMessage
static synchronized boolean handleMessage(@NonNull() Context context, @NonNull() Map<String, String> data, @NonNull() MessageListener listener, Call.CallMessageListener callMessageListener)
Handle messages from FCM.
Twilio sends
{@code call}notification messages via GCM/FCM. The message type is encodedin the dictionary with the key{@code twi_message_type}with the value{@code * twilio.voice.call}.A
{@code call}message is sent when someone wants to reach the registered{@code * identity}. Passing a{@code call}message into handleMessage will result in a CallInvite raised in the MessageListener and return{@code true}.A CancelledCallInvite will be raised to the provided MessageListener forthe following reasons:
- The call is prematurely disconnected by the caller
- The callee does not accept or reject the call within 30 seconds
- The SDK is unable to establish a connection to Twilio
Passing malformed data to handleMessage willreturn
{@code false}and no MessageListener callback will be raised.Insights :
- Parameters:
context- An Android context.data- Push notification payload.listener- A MessageListener to receive incoming push notification callbacks.callMessageListener- a Call.CallMessageListener to receive inbound callmessages.
-
handleMessage
static boolean handleMessage(@NonNull() Context context, @NonNull() Bundle data, @NonNull() MessageListener listener)
Handle messages from GCM.
Twilio sends
{@code call}notification messages via GCM/FCM. The message type is encodedin the dictionary with the key{@code twi_message_type}with the value{@code * twilio.voice.call}.A
{@code call}message is sent when someone wants to reach the registered{@code * identity}. Passing a{@code call}message into handleMessage will result in a CallInvite raised in the MessageListener and return{@code true}.A CancelledCallInvite will be raised to the provided MessageListener forthe following reasons:
- The call is prematurely disconnected by the caller
- The callee does not accept or reject the call within 30 seconds
- The SDK is unable to establish a connection to Twilio
Passing malformed data to handleMessage willreturn
{@code false}and no MessageListener callback will be raised.Insights :
- Parameters:
context- An Android context.data- Push notification payload.listener- A MessageListener to receive incoming push notification callbacks.
-
handleMessage
static boolean handleMessage(@NonNull() Context context, @NonNull() Bundle data, @NonNull() MessageListener listener, Call.CallMessageListener callMessageListener)
Handle messages from GCM.
Twilio sends
{@code call}notification messages via GCM/FCM. The message type is encodedin the dictionary with the key{@code twi_message_type}with the value{@code * twilio.voice.call}.A
{@code call}message is sent when someone wants to reach the registered{@code * identity}. Passing a{@code call}message into handleMessage will result in a CallInvite raised in the MessageListener and return{@code true}.A CancelledCallInvite will be raised to the provided MessageListener forthe following reasons:
- The call is prematurely disconnected by the caller
- The callee does not accept or reject the call within 30 seconds
- The SDK is unable to establish a connection to Twilio
Passing malformed data to handleMessage willreturn
{@code false}and no MessageListener callback will be raised.Insights :
- Parameters:
context- An Android context.data- Push notification payload.listener- A MessageListener to receive incoming push notification callbacks.callMessageListener- a Call.CallMessageListener to receive inbound callmessages.
-
getVersion
@NonNull() static String getVersion()
Returns the version of the Voice SDK.
-
getLogLevel
@NonNull() static LogLevel getLogLevel()
Returns the logging level for messages logged by the Voice SDK. The default level is .
-
isInsightsEnabled
static boolean isInsightsEnabled()
Returns if reporting statistics to Insights is enabled. Sending stats data to Insights isenabled by default. The setting is specified in enableInsights and can beupdated via enableInsights
-
setLogLevel
static void setLogLevel(@NonNull() LogLevel level)
Sets the logging level for messages logged by the Voice SDK.
- Parameters:
level- The logging level
-
enableInsights
static void enableInsights(boolean enable)
Specify reporting statistics to Insights. Sending stats data to Insights is enabled bydefault.
NOTE: Setting the flag during a call will not be applied to ongoing calls. The flag willbe applied to subsequent connect or API calls.
-
-
-
-