Chat Android SDK  7.0.1
com.twilio.chat.ChatClient Class Reference

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

Classes

enum  ConnectionState
 Represents underlying twilsock connection state. More...
 
class  FCMToken
 Class which represents token received by application from the Firebase Cloud Messaging service. More...
 
class  GCMToken
 Class which represents token received by application from the Google Cloud Messaging service. More...
 
class  LogLevel
 Log level constants for passing to setLogLevel. More...
 
class  Properties
 Properties for client initialization configuration. More...
 
enum  SynchronizationStatus
 Represents client initialization status. More...
 

Public Member Functions

Listeners
void addListener (@NonNull ChatClientListener listener)
 Method to add listener for this Client. More...
 
void removeListener (@NonNull ChatClientListener listener)
 Method to remove listener from this Client. More...
 
void removeAllListeners ()
 Method to remove all listeners from this Client.
 
Push notifications
void registerGCMToken (GCMToken token, StatusListener listener)
 Register GCM token for push notification updates. More...
 
void unregisterGCMToken (GCMToken token, StatusListener listener)
 Unregister from push notification updates. More...
 
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 chat library for processing. More...
 

Static Public Member Functions

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

Getters

static String getSdkVersion ()
 Returns the version of the Chat SDK. More...
 
Properties getProperties ()
 Get properties for current client. More...
 
Channels getChannels ()
 Channels available to the ChatClient. More...
 
native ConnectionState getConnectionState ()
 
native String getMyIdentity ()
 Get user identity for current user. More...
 
Users getUsers ()
 Get Users interface. More...
 
native boolean isReachabilityEnabled ()
 Get reachability service status. More...
 

Lifecycle

static void create (@NonNull Context context,@NonNull String token,@NonNull Properties properties,@NonNull CallbackListener< ChatClient > listener)
 Creates a new Chat 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...
 

Detailed Description

Chat client - main entry point for the Chat SDK.

Member Function Documentation

void com.twilio.chat.ChatClient.addListener ( @NonNull ChatClientListener  listener)

Method to add listener for this Client.

Parameters
listenerthe listener to add.
static void com.twilio.chat.ChatClient.create ( @NonNull Context  context,
@NonNull String  token,
@NonNull Properties  properties,
@NonNull CallbackListener< ChatClient listener 
)
static

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

Callback listener is invoked with reference to ChatClient 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 Chat service.
propertiesChatClient initialization properties
listenerCallback listener that will receive reference to the newly initialized ChatClient.
Channels com.twilio.chat.ChatClient.getChannels ( )

Channels available to the ChatClient.

Returns
The channels object for list of channels of this ChatClient.
native ConnectionState com.twilio.chat.ChatClient.getConnectionState ( )
Returns
Current transport state.
native String com.twilio.chat.ChatClient.getMyIdentity ( )

Get user identity for current user.

Returns
User identity for current user
Properties com.twilio.chat.ChatClient.getProperties ( )

Get properties for current client.

Returns
properties for client
static String com.twilio.chat.ChatClient.getSdkVersion ( )
static

Returns the version of the Chat SDK.

Returns
The version of the SDK.
Users com.twilio.chat.ChatClient.getUsers ( )

Get Users interface.

Returns
Users object used to manipulate User subscriptions.
void com.twilio.chat.ChatClient.handleNotification ( NotificationPayload  notification)

Queue the incoming notification with the chat library for processing.

You must call this function if you want the chat library to call your ChatClientListener.onAddedToChannelNotification(), ChatClientListener.onInvitedToChannelNotification(), ChatClientListener.onRemovedFromChannelNotification(), or ChatClientListener.onNewMessageNotification() callbacks.

Parameters
notificationNotification received from GCM or FCM.
native boolean com.twilio.chat.ChatClient.isReachabilityEnabled ( )

Get reachability service status.

Returns
true if reachability info is available, false otherwise.
void com.twilio.chat.ChatClient.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.chat.ChatClient.registerGCMToken ( GCMToken  token,
StatusListener  listener 
)

Register GCM token for push notification updates.

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

Method to remove listener from this Client.

Parameters
listenerthe listener to remove.
static void com.twilio.chat.ChatClient.setLogLevel ( int  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.chat.ChatClient.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.

After calling this method strong references to all objects created and returned by the Chat client must be released (i.e Channel, Message, Member, User etc).

void com.twilio.chat.ChatClient.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.chat.ChatClient.unregisterGCMToken ( GCMToken  token,
StatusListener  listener 
)

Unregister from push notification updates.

Parameters
tokenThe GCMToken to unregister. Must be the same token that was passed in registerGCMToken before.
listenerListener that will receive callback with the result.
void com.twilio.chat.ChatClient.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.