If you are starting out with Twilio's Programmable Chat SDK for Android, we highly recommend starting with version 7.x. Version 7.x is our latest SDK and it brings many new features and improvements to the earliest versions. And it will be much easier to migrate to Twilio Conversations.
Not using 7.x? You should migrate ASAP
If you are already using 4.x, we highly recommend planning your migration to 7.x as soon as possible.
End-of-Life for 1.x occurred on June 30, 2019.
onChannelAdded
called after re-joining to private channel.onChannelAdded
called.joinChannel
callback. Sometimes was not called.makeUserDescriptor()
.isOnline()
and isNotifiable()
in TMUserDescriptor
always returned false
.add
or invite
members double callbacks while offline.getChannel()
.getAndSubscribeUser()
method doesn't work anymore after calling User.unsubscribe()
.getMessageByIndex()
sometimes resulted in Could not retrieve Message by index
error when messages were not cached.ChatClientListener.onNewMessageNotification()
after calling ChatClient.handleNotification()
.Member.getType()
method to obtain information about the type of a member (chat/sms/whatsapp/other).ChannelListener.onTypingStarted()
/ .onTypingEnded()
.Message.getMemberSid()
and Message.getMember()
methods to obtain information about the author of a message.UpdateAttributes
in Message
and User
, now updating with null value calls listener's onError()
.Message.getTimeStampAsDate()
. Use Message.getDateCreatedAsDate()
instead.ChatClient.updateToken()
may now indicate an error to the listener if the token validation failed.Introduced Push Notification Muting, with per-channel user notification preferences.
Added Channel.getNotificationLevel()
and Channel.setNotificationLevel(NotificationLevel, StatusListener)
.
Added Channel.NotificationLevel
enum with values .DEFAULT
to receive notifications and .MUTED
to suppress them. Upon leaving the channel, the mute setting for this User is reset to .DEFAULT
.
Added Channel.UpdateReason.NOTIFICATION_LEVEL
enum value when notification level changes.
NOTE: You need to grant editNotificationLevel
permission to the user roles to be able to change this setting. See the Chat Permissions documentation.
Added new token lifecycle management delegate callbacks which reduce the need for AccessManager integration when only using one Twilio client SDK:
ChatClientListener.onTokenAboutToExpire()
is called when a token has 3 minutes or less left until expiry and should be refreshed.ChatClientListener.onTokenExpired()
is called when a token is already expired and must be refreshed to reconnect to the service.New logging level android.log.LogLevel.VERBOSE
is now supported. Use this value to generate logs when reporting SDK issues to Twilio. As before, the default log setting is .SILENT
, producing no SDK debug output at all.
Added Member.UpdateReason.ATTRIBUTES
enum value. There's currently no way to query member attributes, it will be added in the following SDK version.
Added logging of android.os.Build.{BOARD,BRAND,DEVICE,DISPLAY,FINGERPRINT,HARDWARE,MANUFACTURER,MODEL,PRODUCT}
on ChatClient startup - this data is logged into the local android log only and is helpful in diagnosing problems, please include it when submitting logs in bug reports!
Added @NonNull annotations to methods in Messages
class.
Overhauled transport and communication layer, significantly improving network traffic overhead and client performance.
Provided numerous fixes for improving client stability, focusing on runtime and shutdown crashes.
getLastMessages()
.Message.getTimeStampAsDate()
, use Message.getDateCreatedAsDate()
instead.Channels.getSubscribedChannelsSortedBy()
to obtain a list of subscribed channels sorted based on a few available criteria: Channel.SortCriterion.LAST_MESSAGE
, Channel.SortCriterion.FRIENDLY_NAME
, Channel.SortCriterion.UNIQUE_NAME
.Channel.getLastMessageDate()
and Channel.getLastMessageIndex()
to obtain information about last message activity in the channel.Channel.UpdateReason.LAST_MESSAGE
for last channel message change, you can inspect the two above-mentioned properties of the Channel
after receiving this update for new values.Messages.getLastMessages()
query. It used to be possible to query for 0 messages and receive no results, but not anymore.ChatClient.setLogLevel()
to receive log messages.This version is a major version bump due to semver. There are a number of incompatible API changes making this bump necessary.
These updates have changed the API in a backwards-incompatible manner.
ChannelListener.onTypingStarted/onTypingEnded
methods now include a Channel in which this event has happened in the signature.null
body instead. Be careful to handle this case properly because it may cause NPEs in the your application if you don't.Message.getTimeStamp
has been renamed Message.getDateCreated
for clarity. The returned value has not changed.ChatClientListener.onNotification()
method for receiving push notifications has been split into 4 separate methods:
onNewMessageNotification(String channelSid, String messageSid, long messageIndex)
onAddedToChannelNotification(String channelSid)
onInvitedToChannelNotification(String channelSid)
onRemovedFromChannelNotification(String channelSid)
Now the parameters to these methods are more logical - for example there's no messageSid parameter when it is unused. The new messageIndex
parameter provides an easier interface if you need to scroll to a message in the channel from push notification.Channel.join
and Members.add/addByIdentity
has changed - methods will fail if user is already a member of the channel.Messages.advanceLastConsumedMessageIndex()
, use advanceLastConsumedMessageIndexWithResult()
instead.Messages.setLastConsumedMessageIndex()
, use setLastConsumedMessageIndexWithResult()
instead.Messages.setAllMessagesConsumed()
, use setAllMessagesConsumedWithResult()
instead.Messages.setNoMessagesConsumed()
, use setNoMessagesConsumedWithResult()
instead.ChatClient.create
will be called on the originating thread. Previously it was called from library thread by mistake.setDeferCertificateTrustToPlatform(boolean)
with value true
. By default Twilio-pinned certificate bundle will be used.ChatClientListener.onChannelAdded()
will be called regardless of if the channel's status is known yet or not, it was not called before if channel status was not yet determined.Channel.setType()
removed from the SDK.setLastConsumedMessageIndexWithResult()
advanceLastConsumedMessageIndexWithResult()
setAllMessagesConsumedWithResult()
setNoMessagesConsumedWithResult()
setLastConsumedMessageIndex()
advanceLastConsumedMessageIndex()
setAllMessagesConsumed()
setNoMessagesConsumed()
updateToken()
once again give feedback if the provided token is expired or otherwise invalid.joinChannel
sometimes was not called.Message
were sometimes not fully populated by the time sendMessage
's listener was called.UpdateReason
s to onMessageUpdated and onMemberUpdated callbacks.SynchronizationStrategy
.Message.Options
to construct and sendMessage()
Members.add()
, .addByIdentity()
, .invite()
, .inviteByIdentity()
, .removeByIdentity()
updated to new chat-lib APIupdateToken()
once again give feedback if the provided token is expired or otherwise invalid.joinChannel
sometimes was not called.Message
were sometimes not fully populated by the time sendMessage
's listener was called.channel.join()
listener will be called after joined channel has been completely synchronized.setAllMessagesConsumed()
in an empty channel could cause the SDK client to crash.null
Properties to ChatClient.create()
. An IllegalStateException
will now be thrown instead.Member.getUserDescriptor()/.getAndSubscribeUser()
.Channel.SynchronizationStatus.isAtLeast()
.client.shutdown()
sometimes caused New Message push registrations to be lost for the endpoint.Changes are grouped by class to ease migration.
Log.DEBUG
to Log.WARN
int getInitialMessageCount()
Builder ChatClient.Builder.setInitialMessageCount(int initialMessageCount)
UserInfo getMyUserInfo()
with String getMyIdentity()
Users getUsers()
void onUserSubscribed(User user)
void onUserUnsubscribed(User user)
onChannelAdd
to onChannelAdded
onChannelJoin
to onChannelJoined
onChannelInvite
to onChannelInvited
onChannelDelete
to onChannelDeleted
onToastNotification
to onNotification
onToastSubscribed
to onNotificationSubscribed
onToastFailed
to onNotificationFailed
void onChannelChange(Channel)
with void onChannelUpdated(Channel, Channel.UpdateReason reason)
void onUserInfoChange(UserInfo userInfo, UserInfo.UpdateReason reason)
with void onUserUpdated(User user, User.UpdateReason reason)
Channel.ChannelStatus
enum:
UNKNOWN
- channels returned in ChannelDescriptor do not have status informationChannel.UpdateReason
enum to indicate reason for channel update, with values:
STATUS
LAST_CONSUMED_MESSAGE_INDEX
UNIQUE_NAME
FRIENDLY_NAME
ATTRIBUTES
void synchronize(CallbackListener<Channel>)
long getUnconsumedMessagesCount()
Channel.ChannelStatus getStatus()
getPublicChannels
to getPublicChannelsList
void getUserChannelsList(CallbackListener<Paginator<ChannelDescriptor>>)
List<Channel> getSubscribedChannels()
List<Member> getMembersByIdentity(String identity)
onMessageAdd
to onMessageAdded
onMessageChange
to onMessageUpdated
onMessageDelete
to onMessageDeleted
onMemberJoin
to onMemberJoined
onMemberAdd
to onMemberAdded
onMemberChange
to onMemberUpdated
onMemberDelete
to onMemberDeleted
onSynchronizationChange
to onSynchronizationChanged
int getStatus()
String toString()
getErrorCode
to getCode
getErrorText
to getMessage
void getUserDescriptor(CallbackListener<UserDescriptor> listener)
void getAndSubscribeUser(CallbackListener<User> listener)
UserInfo getUserInfo()
with String getIdentity()
Channel getChannel()
Member getMember(String identity)
void add(Member member, StatusListener listener)
void invite(Member member, StatusListener listener)
void removeByIdentity(String identity, StatusListener listener)
void getMembers(CallbackListener<Paginator<Member>> listener)
with List<Member> getMembersList()
removeMember
to remove
UserInfo
to User
classvoid unsubscribe()
boolean isSubscribed()
UserDescriptor
with functions:
String getFriendlyName()
JSONObject getAttributes()
String getIdentity()
boolean isOnline()
boolean isNotifiable()
subscribe(CallbackListener<User> listener)
Users
with functions:
void getChannelUserDescriptors(String channelSid, CallbackListener<Paginator<UserDescriptor>> listener)
void getUserDescriptor(String identity, CallbackListener<UserDescriptor> listener)
void getAndSubscribeUser(String identity, CallbackListener<User> listener)
List<User> getSubscribedUsers()
User getMyUser()
onChannelAdded
and onChannelJoined
events failed to fire correctly\v
endpoint_id
identifier specified in access tokens is now automatically generated and persisted in the local app storage. The following should be observed with this change:
endpoint_id
is no longer a required identifier in your generated access tokens, you may omit it from this build forwardendpoint_id
will be ignored if specified with your access tokenChannel.getCreatedBy()
and ChannelDescriptor.getCreatedBy()
to return creator's identityonClientSynchronization
callback in the registered listener upon ChatClient.setListener()
, passing the current client synchronization stategetPublicChannels()
caused a crashIP Messaging
to Programmable Chat
IPMessagingClient
is renamed to ChatClient
com.twilio.ipmessaging
is renamed to com.twilio.chat
Channel.removeAllListeners()
removes all added listeners.Channel.getMessagesCount()
Channel.getUnconsumedMessagesCount()
Channel.getMembersCount()
Channels.getPublicChannels()
returns ChannelDescriptor
s, and this list is not updated in realtime.onUserInfoUpdated
added UpdateReason.BREAKING Do not return IPMessagingClient before it was fully initialized.
IPMessagingClient.create()
no longer returns a value, you
can obtain reference to created IPMessagingClient only in listener's onSuccess()
callback.
BREAKING Channel.setListener()
replaced with addListener()
to support assigning multiple listeners
BREAKING Channel.removeListener()
now accepts listener ptr to remove only that one
BREAKING Replace custom CreateChannelListener
in Channels.createChannel()
with generic CallbackListener<Channel>
. Listener's onCreated(Channel)
is therefore renamed onSuccess(Channel)
.
BREAKING IPMessagingClient.handleNotification()
now accepts NotificationPayload
instead of Map<String,String>
BREAKING Messages.getMessageByIndex()
has been changed to asynchronous interface.
BREAKING Members.getMembers()
has been changed to asynchronous interface.
BREAKING Channel invite logic changes.
BREAKING Constants
interface is removed, StatusListener
and CallbackListener<T>
are standalone classes now.
BREAKING Removed built-in AccessManager, IPMessagingClient.create()
now accepts only String token. IPMessagingClient.updateToken()
is provided to update it.
BREAKING Remove previously obsoleted ChannelListener.onAttributesChange()
BREAKING Remove previously deprecated Channels.createChannel()
with attributes map.
BREAKING Remove previously deprecated TwilioIPMessagingSDK
BREAKING Remove previously deprecated InitListener
BREAKING Remove previously deprecated Messages.getMessages()