Conversations Android SDK  1.0.1
com.twilio.conversations.ConversationsClient Interface Reference

Conversations client - main entry point for the Conversations SDK. More...

Classes

enum  ConnectionState
 Represents underlying twilsock connection state. More...
 
interface  ConversationBuilder
 Helper to create new conversation with provided data. More...
 
class  FCMToken
 Class which represents token received by application from the Firebase Cloud Messaging service. More...
 
enum  LogLevel
 Log level constants for passing to setLogLevel. More...
 
interface  Properties
 Properties for client initialization configuration. More...
 
enum  SynchronizationStatus
 Represents client initialization status. More...
 

Public Member Functions

Listeners
void addListener (@NonNull ConversationsClientListener listener)
 Method to add listener for this Client. More...
 
void removeListener (@NonNull ConversationsClientListener listener)
 Method to remove listener from this Client. More...
 
void removeAllListeners ()
 Method to remove all listeners from this Client.
 
Push notifications
void registerFCMToken (FCMToken token, StatusListener listener)
 Register Firebase Messaging token for push notification updates. More...
 
void unregisterFCMToken (FCMToken token, StatusListener listener)
 Unregister from Firebase Messaging updates. More...
 
void handleNotification (NotificationPayload notification)
 Queue the incoming notification with the conversations library for processing. More...
 
Users
void getAndSubscribeUser (String identity, CallbackListener< User > listener)
 Get user based on user identity and subscribe to real-time updates for this user. More...
 
List< UsergetSubscribedUsers ()
 Get a list of currently subscribed User objects. More...
 
User getMyUser ()
 Get logged in User object. More...
 
Conversations
void createConversation (String friendlyName, CallbackListener< Conversation > listener)
 Create a conversation with friendly name. More...
 
ConversationBuilder conversationBuilder ()
 Get ConversationBuilder to create conversation with options. More...
 
void getConversation (String conversationSidOrUniqueName, CallbackListener< Conversation > listener)
 Retrieves a conversation with the specified SID or unique name. More...
 
List< ConversationgetMyConversations ()
 Request list of user's joined conversations. More...
 
boolean isReachabilityEnabled ()
 Get reachability service status. More...
 

Static Public Member Functions

static void setLogLevel (LogLevel level)
 Set verbosity level for log messages to be printed to android logcat. More...
 

Lifecycle

static void create (@NonNull Context context,@NonNull String token,@NonNull Properties properties,@NonNull CallbackListener< ConversationsClient > listener)
 Creates a new Conversations client instance with a token manager and client properties. More...
 
void updateToken (String token, StatusListener listener)
 Method to update the authentication token for this client. More...
 
void shutdown ()
 Cleanly shuts down the messaging client when you are done with it. More...
 

Getters

static String getSdkVersion ()
 Returns the version of the Conversations SDK. More...
 
Properties getProperties ()
 Get properties for current client. More...
 
ConnectionState getConnectionState ()
 
String getMyIdentity ()
 Get user identity for current user. More...
 
List< ParticipantgetParticipantsByIdentity (String identity)
 Get list of all Conversation participants with a given identity. More...
 

Detailed Description

Conversations client - main entry point for the Conversations SDK.

Member Function Documentation

void com.twilio.conversations.ConversationsClient.addListener ( @NonNull ConversationsClientListener  listener)

Method to add listener for this Client.

Parameters
listenerthe listener to add.
ConversationBuilder com.twilio.conversations.ConversationsClient.conversationBuilder ( )

Get ConversationBuilder to create conversation with options.

A pattern to build conversation with options is:

Returns
A ConversationBuilder used to create conversation with options.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.

Example

.withFriendlyName("Conversation")
.build(listener);
static void com.twilio.conversations.ConversationsClient.create ( @NonNull Context  context,
@NonNull String  token,
@NonNull Properties  properties,
@NonNull CallbackListener< ConversationsClient listener 
)
static

Creates a new Conversations client instance with a token manager and client properties.

Callback listener is invoked with reference to ConversationsClient when client initialization is completed.

Parameters
contextThe Application Context from your Android application. Make sure you don't pass an Activity Context. You can retrieve the Application Context by calling getApplicationContext() on your Activity. Cannot be null.
tokenAccess token for Conversations service.
propertiesConversationsClient initialization properties
listenerCallback listener that will receive reference to the newly initialized ConversationsClient.
void com.twilio.conversations.ConversationsClient.createConversation ( String  friendlyName,
CallbackListener< Conversation listener 
)

Create a conversation with friendly name.

This operation creates a new conversation entity on the backend.

Parameters
friendlyNameFriendly name of the new conversation.
listenerListener that receives the status of create conversation action.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
void com.twilio.conversations.ConversationsClient.getAndSubscribeUser ( String  identity,
CallbackListener< User listener 
)

Get user based on user identity and subscribe to real-time updates for this user.

There's a limit on the number of simultaneously subscribed objects in the SDK. This is to reduce consumed memory and network traffic.

Parameters
identityUser identity to query.
listenerListener to receive resulting subscribed User object.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
See also
getSubscribedUsers
ConnectionState com.twilio.conversations.ConversationsClient.getConnectionState ( )
Returns
Current transport state.
void com.twilio.conversations.ConversationsClient.getConversation ( String  conversationSidOrUniqueName,
CallbackListener< Conversation listener 
)

Retrieves a conversation with the specified SID or unique name.

Parameters
conversationSidOrUniqueNameIdentifier for the conversation.
listenerListener to receive the conversation.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
List<Conversation> com.twilio.conversations.ConversationsClient.getMyConversations ( )

Request list of user's joined conversations.

Returns
A list of Conversations that are joined to.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
String com.twilio.conversations.ConversationsClient.getMyIdentity ( )

Get user identity for current user.

Returns
User identity for current user
User com.twilio.conversations.ConversationsClient.getMyUser ( )

Get logged in User object.

Returns the User object for your currently logged in User. You can query and update this object at will.

Returns
Own User object.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
List<Participant> com.twilio.conversations.ConversationsClient.getParticipantsByIdentity ( String  identity)

Get list of all Conversation participants with a given identity.

The effect of this function is to find and return all Participant instances across multiple conversations with the given identity.

Parameters
identityParticipant identity to look up.
Returns
List of Participants across Conversations with given identity.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
Properties com.twilio.conversations.ConversationsClient.getProperties ( )

Get properties for current client.

Returns
properties for client
static String com.twilio.conversations.ConversationsClient.getSdkVersion ( )
static

Returns the version of the Conversations SDK.

Returns
The version of the SDK.
List<User> com.twilio.conversations.ConversationsClient.getSubscribedUsers ( )

Get a list of currently subscribed User objects.

These objects receive status updates in real-time. When you subcribe to too many users simultaneously, the oldest subscribed users will be automatically unsubscribed.

Returns
List of subscribed User objects.
Exceptions
IllegalStateExceptionIf ConversationClient isn't synchronized properly.
void com.twilio.conversations.ConversationsClient.handleNotification ( NotificationPayload  notification)

Queue the incoming notification with the conversations library for processing.

You must call this function if you want the conversations library to call your ConversationsClientListener#onAddedToConversationNotification, ConversationsClientListener#onRemovedFromConversationNotification, or ConversationsClientListener#onNewMessageNotification callbacks.

Parameters
notificationNotification received from FCM.
boolean com.twilio.conversations.ConversationsClient.isReachabilityEnabled ( )

Get reachability service status.

Returns
true if reachability info is available, false otherwise.
void com.twilio.conversations.ConversationsClient.registerFCMToken ( FCMToken  token,
StatusListener  listener 
)

Register Firebase Messaging token for push notification updates.

Parameters
tokenThe registration token an Android application needs to register with FCM connection servers before it can receive messages.
listenerListener that will receive callback with the result.
void com.twilio.conversations.ConversationsClient.removeListener ( @NonNull ConversationsClientListener  listener)

Method to remove listener from this Client.

Parameters
listenerthe listener to remove.
static void com.twilio.conversations.ConversationsClient.setLogLevel ( LogLevel  level)
static

Set verbosity level for log messages to be printed to android logcat.

Default log level is LogLevel#SILENT.

Parameters
levelVerbosity level. See LogLevel for supported options.
void com.twilio.conversations.ConversationsClient.shutdown ( )

Cleanly shuts down the messaging client when you are done with it.

It will dispose() the client after shutdown, so it could not be reused.

void com.twilio.conversations.ConversationsClient.unregisterFCMToken ( FCMToken  token,
StatusListener  listener 
)

Unregister from Firebase Messaging updates.

Parameters
tokenThe FCMToken to unregister. Must be the same token that was passed in registerFCMToken before.
listenerListener that will receive callback with the result.
void com.twilio.conversations.ConversationsClient.updateToken ( String  token,
StatusListener  listener 
)

Method to update the authentication token for this client.

Parameters
tokenA new access token for this Client.
listenerListener that will receive callback with the result.