public final class ChatClient
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
ChatClient.ConnectionState
Represents underlying twilsock connection state.
|
static class |
ChatClient.Properties
Properties for client initialization configuration
|
static class |
ChatClient.SynchronizationStatus
Represents client initialization status.
|
Modifier and Type | Method and Description |
---|---|
static void |
create(android.content.Context context,
java.lang.String token,
ChatClient.Properties properties,
CallbackListener<ChatClient> listener)
Creates a new Chat client instance with a token manager and client properties.
|
void |
dispose() |
Channels |
getChannels()
Channels available to the ChatClient.
|
ChatClient.ConnectionState |
getConnectionState() |
java.lang.String |
getMyIdentity()
Get user identity for current user
|
ChatClient.Properties |
getProperties()
Get properties for current client
|
static java.lang.String |
getSdkVersion()
Returns the version of the Chat SDK.
|
Users |
getUsers() |
void |
handleNotification(NotificationPayload notification)
Queue the incoming notification with the messaging library for processing.
|
boolean |
isReachabilityEnabled()
Get reachability service status.
|
void |
onMemberAdded(Member member)
Called when a Member is added to the channel the current user is subscribed to.
|
void |
onMemberDeleted(Member member)
Called when a Member is deleted from the channel the current user is subscribed to.
|
void |
onMemberUpdated(Member member,
Member.UpdateReason reason)
Called when a Member is changed in the channel the current user is subscribed to.
|
void |
onMessageAdded(Message message)
Called when a Message is added to the channel the current user is subscribed to.
|
void |
onMessageDeleted(Message message)
Called when a Message is deleted from the channel the current user is subscribed to.
|
void |
onMessageUpdated(Message message,
Message.UpdateReason reason)
Called when a Message is changed in the channel the current user is subscribed to.
|
void |
onSynchronizationChanged(Channel channel)
Called when channel synchronization status changed.
|
void |
onTypingEnded(Member member)
Called when an Member stops typing in a Channel.
|
void |
onTypingStarted(Member member)
Called when an Member starts typing in a Channel.
|
void |
registerFCMToken(java.lang.String token,
StatusListener listener)
Register Firebase Messaging token for push notification updates.
|
void |
registerGCMToken(java.lang.String token,
StatusListener listener)
Register GCM token for push notification updates.
|
void |
removeListener()
Method to remove listener for this Client.
|
void |
setListener(ChatClientListener listener)
Method to set listener for this Client.
|
static void |
setLogLevel(int level) |
void |
shutdown()
Cleanly shuts down the messaging client when you are done with it.
|
void |
unregisterFCMToken(java.lang.String token,
StatusListener listener)
Unregister from Firebase Messaging updates.
|
void |
unregisterGCMToken(java.lang.String token,
StatusListener listener)
Unregister from push notification updates.
|
void |
updateToken(java.lang.String token,
StatusListener listener)
Method to update the authentication token for this client.
|
public static java.lang.String getSdkVersion()
public static void create(@NonNull android.content.Context context, @NonNull java.lang.String token, @NonNull ChatClient.Properties properties, @NonNull CallbackListener<ChatClient> listener)
context
- The 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.token
- Access token for Chat service.properties
- ChatClient initialization propertieslistener
- Callback listener that will receive reference to
the newly initialized ChatClient.public void updateToken(java.lang.String token, StatusListener listener)
token
- A new access token for this Client.listener
- Listener that will receive callback with the result.public Channels getChannels()
public void registerGCMToken(java.lang.String token, StatusListener listener)
token
- The registration token an Android application needs to register with GCM
connection servers before it can receive messages.listener
- Listener that will receive callback with the result.public void unregisterGCMToken(java.lang.String token, StatusListener listener)
token
- The registration token provided for GCM push notification registration.listener
- Listener that will receive callback with the result.public void registerFCMToken(java.lang.String token, StatusListener listener)
token
- The registration token an Android application needs to register with FCM
connection servers before it can receive messages.listener
- Listener that will receive callback with the result.public void unregisterFCMToken(java.lang.String token, StatusListener listener)
token
- The registration token provided for FCM push notification registration.listener
- Listener that will receive callback with the result.public void handleNotification(NotificationPayload notification)
notification
- Notification received from GCMpublic ChatClient.Properties getProperties()
public void shutdown()
public ChatClient.ConnectionState getConnectionState()
public java.lang.String getMyIdentity()
public Users getUsers()
public boolean isReachabilityEnabled()
public void dispose()
public static void setLogLevel(int level)
public void setListener(ChatClientListener listener)
listener
- the listener for this Client.public void removeListener()
public void onMessageAdded(Message message)
ChannelListener
You could obtain the Channel where it was added by
using Message.getChannel()
or
Message.getChannelSid()
.
onMessageAdded
in interface ChannelListener
message
- The message that has been added.ChannelListener.onMessageUpdated(com.twilio.chat.Message, com.twilio.chat.Message.UpdateReason)
,
ChannelListener.onMessageDeleted(com.twilio.chat.Message)
public void onMessageUpdated(Message message, Message.UpdateReason reason)
ChannelListener
You could obtain the Channel where it was changed by
using Message.getChannel()
or
Message.getChannelSid()
.
Message change events include body
updates
and attribute
updates.
onMessageUpdated
in interface ChannelListener
message
- The message that changed.reason
- Reason for the update.ChannelListener.onMessageAdded(com.twilio.chat.Message)
,
ChannelListener.onMessageDeleted(com.twilio.chat.Message)
public void onMessageDeleted(Message message)
ChannelListener
You could obtain the Channel where it was deleted from by
using Message.getChannel()
or Message.getChannelSid()
.
onMessageDeleted
in interface ChannelListener
message
- The message that got deleted.ChannelListener.onMessageAdded(com.twilio.chat.Message)
,
ChannelListener.onMessageUpdated(com.twilio.chat.Message, com.twilio.chat.Message.UpdateReason)
public void onMemberAdded(Member member)
ChannelListener
You could obtain the Channel it was added to by using Member.getChannel()
.
onMemberAdded
in interface ChannelListener
member
- The member that joined.ChannelListener.onMemberUpdated(com.twilio.chat.Member, com.twilio.chat.Member.UpdateReason)
,
ChannelListener.onMemberDeleted(com.twilio.chat.Member)
public void onMemberUpdated(Member member, Member.UpdateReason reason)
ChannelListener
You could obtain the Channel where it was changed by using Member.getChannel()
.
Member change events include consumption horizon
updates, reachability status
updates
and user profile
updates.
onMemberUpdated
in interface ChannelListener
member
- The member that changed.reason
- Reason for the update.ChannelListener.onMemberAdded(com.twilio.chat.Member)
,
ChannelListener.onMemberDeleted(com.twilio.chat.Member)
public void onMemberDeleted(Member member)
ChannelListener
You could obtain the Channel it was deleted from by using Member.getChannel()
.
onMemberDeleted
in interface ChannelListener
member
- The member that was deleted.ChannelListener.onMemberAdded(com.twilio.chat.Member)
,
ChannelListener.onMemberUpdated(com.twilio.chat.Member, com.twilio.chat.Member.UpdateReason)
public void onTypingStarted(Member member)
ChannelListener
You could obtain the Channel from the Member using Member.getChannel()
.
onTypingStarted
in interface ChannelListener
member
- The member that started typing.ChannelListener.onTypingEnded(com.twilio.chat.Member)
public void onTypingEnded(Member member)
ChannelListener
You could obtain the Channel from the Member using Member.getChannel()
.
Typing indicator has a timeout after user stops typing to avoid triggering it too often. Expect about 5 seconds delay between stopping typing and receiving typing ended event.
onTypingEnded
in interface ChannelListener
member
- The member that stopped typing.ChannelListener.onTypingStarted(com.twilio.chat.Member)
public void onSynchronizationChanged(Channel channel)
ChannelListener
onSynchronizationChanged
in interface ChannelListener
channel
- Channel for which synchronization status has changed.Channel.SynchronizationStatus