Chat Android SDK  4.0.4
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  Properties
 Properties for client initialization configuration. More...
 
enum  SynchronizationStatus
 Represents client initialization status. More...
 

Public Member Functions

Listeners
void setListener (ChatClientListener listener)
 Method to set listener for this Client. More...
 
void removeListener ()
 Method to remove listener for this Client.
 
Push notifications
void registerGCMToken (String token, StatusListener listener)
 Register GCM token for push notification updates. More...
 
void unregisterGCMToken (String token, StatusListener listener)
 Unregister from push notification updates. More...
 
void registerFCMToken (String token, StatusListener listener)
 Register Firebase Messaging token for push notification updates. More...
 
void unregisterFCMToken (String token, StatusListener listener)
 Unregister from Firebase Messaging updates. More...
 
void handleNotification (NotificationPayload notification)
 Queue the incoming notification with the chat library for processing. More...
 

Getters

static String getSdkVersion ()
 Returns the version of the Chat SDK. More...
 
Properties getProperties ()
 Get properties for current client. More...
 
native Channels getChannels ()
 Channels available to the ChatClient. More...
 
native ConnectionState getConnectionState ()
 
native String getMyIdentity ()
 Get user identity for current user. More...
 
native 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

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.
native 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.
native 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 ( String  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 ( String  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.setListener ( ChatClientListener  listener)

Method to set listener for this Client.

Parameters
listenerthe listener for this Client.
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.

void com.twilio.chat.ChatClient.unregisterFCMToken ( String  token,
StatusListener  listener 
)

Unregister from Firebase Messaging updates.

Parameters
tokenThe registration token provided for FCM push notification registration.
listenerListener that will receive callback with the result.
void com.twilio.chat.ChatClient.unregisterGCMToken ( String  token,
StatusListener  listener 
)

Unregister from push notification updates.

Parameters
tokenThe registration token provided for GCM push notification registration.
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.