Chat Android SDK
4.0.2
|
Container for channel object. More...
Classes | |
enum | ChannelStatus |
Represents the various states of the user with respect to the channel. More... | |
enum | ChannelType |
Represents the channel's visibility. More... | |
enum | NotificationLevel |
User's notification level on a channel. More... | |
enum | SynchronizationStatus |
Indicates synchronization status for channel. More... | |
enum | UpdateReason |
Indicates reason for channel update. More... | |
Public Member Functions | |
void | dispose () |
Dispose Channel object, freeing all allocated resources. More... | |
Getters | |
native String | getSid () |
Get unique identifier for this channel. More... | |
native String | getFriendlyName () |
Get friendly name of the channel. More... | |
native NotificationLevel | getNotificationLevel () |
The current user's notification level on this channel. More... | |
native ChannelType | getType () |
Get channel type. More... | |
native String | getUniqueName () |
Get unique name of the channel. More... | |
JSONObject | getAttributes () throws JSONException |
Get custom attributes associated with the Channel. More... | |
native Messages | getMessages () |
Get messages object that allows access to messages in the channel. More... | |
native ChannelStatus | getStatus () |
Get the current user's participation status on this channel. More... | |
native Members | getMembers () |
Get members object that allows access to member roster in the channel. More... | |
native SynchronizationStatus | getSynchronizationStatus () |
Get the current synchronization status for channel. More... | |
native String | getDateCreated () |
Get creation date of the channel as an ISO 8601 string. More... | |
Date | getDateCreatedAsDate () |
Get creation date of the channel. More... | |
native String | getCreatedBy () |
Get creator of the channel. More... | |
native String | getDateUpdated () |
Get update date of the channel as an ISO 8601 string. More... | |
Date | getDateUpdatedAsDate () |
Get update date of the channel. More... | |
Date | getLastMessageDate () |
Get last message date in the channel. More... | |
native Long | getLastMessageIndex () |
Get last message's index in the channel. More... | |
Setters | |
void | setFriendlyName (String friendlyName, StatusListener listener) |
Update the friendly name for this channel. More... | |
void | setNotificationLevel (NotificationLevel notificationLevel, StatusListener listener) |
Set the user's notification level for the channel. More... | |
void | setUniqueName (String uniqueName, StatusListener listener) |
Update the unique name for this channel. More... | |
void | setAttributes (JSONObject updatedAttributes, StatusListener listener) |
Update the attribute data for this channel. More... | |
Listeners | |
void | addListener (ChannelListener listener) |
Add a new ChannelListener for this Channel. More... | |
void | removeListener (ChannelListener listener) |
Remove ChannelListener for this Channel. More... | |
void | removeAllListeners () |
Remove all ChannelListeners for this Channel. More... | |
Actions | |
void | join (StatusListener listener) |
Join the current user to this channel. More... | |
void | leave (StatusListener listener) |
Leave this channel. More... | |
void | destroy (StatusListener listener) |
Destroy the current channel. More... | |
void | declineInvitation (StatusListener listener) |
Decline an invite to this channel. More... | |
native void | typing () |
Indicate that Member is typing in this channel. More... | |
Counts | |
void | getMessagesCount (CallbackListener< Long > listener) |
Get total number of messages in the channel. More... | |
void | getUnconsumedMessagesCount (CallbackListener< Long > listener) |
Get number of unconsumed messages in the channel. More... | |
void | getMembersCount (CallbackListener< Long > listener) |
Get total number of members in the channel roster. More... | |
Container for channel object.
To obtain a Channel call Channels.createChannel(), Channels.getChannel() or get it from collections returned by Channels.getPublicChannelsList() and Channels.getUserChannelsList().
Channel is a relatively heavy-weight object. It receives state updates from the back-end in real time.
void com.twilio.chat.Channel.addListener | ( | ChannelListener | listener | ) |
Add a new ChannelListener for this Channel.
Channel listeners receive real time updates about changes in the channel state, messages and members.
This listener will be called on the originating thread if it has a Looper, otherwise on the main UI thread.
listener | A channel listener. |
void com.twilio.chat.Channel.declineInvitation | ( | StatusListener | listener | ) |
Decline an invite to this channel.
If a user is invited to the channel, they can choose to either join() the channel to accept the invitation or declineInvitation() to decline.
listener | Listener that will receive callback with the result. |
void com.twilio.chat.Channel.destroy | ( | StatusListener | listener | ) |
Destroy the current channel.
Note: this will delete the Channel and all associated metadata from the service instance. Members in the channel and all channel messages, including posted media will be lost.
There is no undo for this operation!
listener | Listener that will receive callback with the result. |
void com.twilio.chat.Channel.dispose | ( | ) |
JSONObject com.twilio.chat.Channel.getAttributes | ( | ) | throws JSONException |
Get custom attributes associated with the Channel.
Attributes are stored as a JSON format object, of arbitrary internal structure. Channel attributes are limited in size to 32Kb.
JSONException | Attributes could not be parsed as JSON. |
native String com.twilio.chat.Channel.getCreatedBy | ( | ) |
Get creator of the channel.
native String com.twilio.chat.Channel.getDateCreated | ( | ) |
Get creation date of the channel as an ISO 8601 string.
Date com.twilio.chat.Channel.getDateCreatedAsDate | ( | ) |
Get creation date of the channel.
native String com.twilio.chat.Channel.getDateUpdated | ( | ) |
Get update date of the channel as an ISO 8601 string.
Update date changes when channel attributes, friendly name or unique name are modified. It will not change in response to messages posted or members added or removed.
Date com.twilio.chat.Channel.getDateUpdatedAsDate | ( | ) |
Get update date of the channel.
Update date changes when channel attributes, friendly name or unique name are modified. It will not change in response to messages posted or members added or removed.
native String com.twilio.chat.Channel.getFriendlyName | ( | ) |
Get friendly name of the channel.
Friendly name is a free-form text string, it is not unique and could be used for user-friendly channel name display in the UI.
Date com.twilio.chat.Channel.getLastMessageDate | ( | ) |
Get last message date in the channel.
native Long com.twilio.chat.Channel.getLastMessageIndex | ( | ) |
Get last message's index in the channel.
native Members com.twilio.chat.Channel.getMembers | ( | ) |
void com.twilio.chat.Channel.getMembersCount | ( | CallbackListener< Long > | listener | ) |
Get total number of members in the channel roster.
This function performs an async call to service to obtain up-to-date member count. The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
listener | Listener to receive results of the query. |
native Messages com.twilio.chat.Channel.getMessages | ( | ) |
void com.twilio.chat.Channel.getMessagesCount | ( | CallbackListener< Long > | listener | ) |
Get total number of messages in the channel.
This function performs an async call to service to obtain up-to-date message count. The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
listener | Listener to receive results of the query. |
native NotificationLevel com.twilio.chat.Channel.getNotificationLevel | ( | ) |
The current user's notification level on this channel.
This property reflects whether the user will receive push notifications for activity on this channel.
native String com.twilio.chat.Channel.getSid | ( | ) |
Get unique identifier for this channel.
This identifier can be used to get this Channel again using Channels.getChannel().
The channel SID is persistent and globally unique.
native ChannelStatus com.twilio.chat.Channel.getStatus | ( | ) |
Get the current user's participation status on this channel.
native SynchronizationStatus com.twilio.chat.Channel.getSynchronizationStatus | ( | ) |
Get the current synchronization status for channel.
native ChannelType com.twilio.chat.Channel.getType | ( | ) |
Get channel type.
void com.twilio.chat.Channel.getUnconsumedMessagesCount | ( | CallbackListener< Long > | listener | ) |
Get number of unconsumed messages in the channel.
This function performs an async call to service to obtain up-to-date message count. The retrieved value is then cached for 5 seconds so there is no reason to call this function more often than once in 5 seconds.
listener | Listener to receive results of the query. |
native String com.twilio.chat.Channel.getUniqueName | ( | ) |
Get unique name of the channel.
Unique name is similar to SID but can be specified by the user.
void com.twilio.chat.Channel.join | ( | StatusListener | listener | ) |
Join the current user to this channel.
Joining the channel is a prerequisite for sending and receiving messages in the channel. You can join the channel or you could be added to it by another channel member.
You could also be invited to the channel by another member. In this case you will not be added to the channel right away but instead receive a onChannelInvited() callback. You accept the invitation by calling join() or decline it by calling declineInvitation().
listener | Listener that will receive callback with the result. |
void com.twilio.chat.Channel.leave | ( | StatusListener | listener | ) |
Leave this channel.
listener | Listener that will receive callback with the result. |
void com.twilio.chat.Channel.removeAllListeners | ( | ) |
Remove all ChannelListeners for this Channel.
void com.twilio.chat.Channel.removeListener | ( | ChannelListener | listener | ) |
Remove ChannelListener for this Channel.
listener | Listener to remove. |
void com.twilio.chat.Channel.setAttributes | ( | JSONObject | updatedAttributes, |
StatusListener | listener | ||
) |
Update the attribute data for this channel.
Attributes are stored as a JSON format object, of arbitrary internal structure. Channel attributes are limited in size to 32Kb.
Passing null attributes will reset channel attributes string to empty.
updatedAttributes | attributes to change. |
listener | Listener that will receive callback with the result. |
void com.twilio.chat.Channel.setFriendlyName | ( | String | friendlyName, |
StatusListener | listener | ||
) |
Update the friendly name for this channel.
friendlyName | New friendly name. |
listener | Listener that will receive callback with the status of update operation. |
void com.twilio.chat.Channel.setNotificationLevel | ( | NotificationLevel | notificationLevel, |
StatusListener | listener | ||
) |
Set the user's notification level for the channel.
This property determines whether the user will receive push notifications for activity on this channel.
notificationLevel | The new notification level for the current user on this channel. |
listener | Listener that will receive callback with the status of update operation. |
void com.twilio.chat.Channel.setUniqueName | ( | String | uniqueName, |
StatusListener | listener | ||
) |
Update the unique name for this channel.
Unique name is unique within Service Instance. You will receive an error if you try to set a name that is not unique.
uniqueName | New unique name for this channel. |
listener | Listener that will receive callback with the result. |
native void com.twilio.chat.Channel.typing | ( | ) |
Indicate that Member is typing in this channel.
You should call this method to indicate that a local user is entering a message into current channel. The typing state is forwarded to users subscribed to this channel through ChannelListener.onTypingStarted() and ChannelListener.onTypingEnded() callbacks.
After approximately 5 seconds after the last typing() call the SDK will emit ChannelListener.onTypingEnded() signal.
One common way to implement this indicator is to call typing() repeatedly in response to key input events.