Migrate your Chat Android SDK to Conversations
We are happy you decided to migrate your Programmable Chat Android SDK to Conversations. It is a great decision and this guide will simplify the process a lot. You will need to perform several rather mechanical changes to convert your existing application code utilizing Twilio Chat to Conversations. One thing is important here, you will need to use Programmable Chat Android SDK 6.0.0 as a minimal version to be able to migrate without any breaking changes.
Add to your project's build.gradle
the following compile options, necessary to use Java8 syntax features:
1compileOptions {2sourceCompatibility JavaVersion.VERSION_1_83targetCompatibility JavaVersion.VERSION_1_84}56// Also if kotlin is used in the project7kotlinOptions {8jvmTarget = '1.8'9}
Rename java package imports from com.twilio.chat
to com.twilio.conversations
ChatClient
toConversationsClient
Channel
toConversation
Member
toParticipant
- Public channels:
ConversationsClient.getConversation(sid)
now returns error codeCONVERSATION_NOT_FOUND
if channel with the given SID is public. Media.download()
is removed, useMessage.getMediaContentTemporaryUrl()
instead.getSubscribedChannelsSortedBy()
method. Sort list returned byConversationsClient.getMyConversations()
instead.ChannelDescriptor
,UserDescriptor
are not needed anymore and removed. UseConversation
andUser
objects instead.Paginator
class is not used anymore and is removed.- Invites to a channel are not supported. Use
Conversation.addParticipantByIdentity()
andaddParticipantByAddress()
instead. onConversationJoined()
callback is temporarily removed. UseonConversationAdded()
instead.Conversation
doesn't implementParcelable
interface anymore. Instead store Conversation objects in your ViewModel or Repository following the Recommended app architecture. UseConversation.sid
as unique key if necessary to pass around and retrieve the Conversation information.
someMethod()
here indicates any of the methods existing previously on certain objects, now they are slightly moved to make API more convenient to use.
ChatClient.getChannels().someMethod()
becomesConversationsClient.someMethod()
Channel.getMembers().somMethod()
becomesConversation.someMethod()
Channel.getMessages().someMethod()
becomesConversation.someMethod()
Message.getMedia().someMethod()
becomesMessage.getMediaSomeMethod()
ChatClient.getUsers().someMethod()
becomesConversationsClient.someMethod()
ChatClient.getSubscribedChannels()
becomesConversationsClient.getMyConversations()
This highlights the fact that this horizon is best useful for implementing messages that have been read. Delivery horizon could be implemented through a combination of delivery receipts and custom attributes on messages.
getLastConsumedMessageIndex()
→getLastReadMessageIndex()
setNoMessagesConsumedWithResult()
→setAllMessagesUnread()
setAllMessagesConsumedWithResult()
→setAllMessagesRead()
setLastConsumedMessageIndexWithResult()
→setLastReadMessageIndex()
advanceLastConsumedMessageIndexWithResult()
→advanceLastReadMessageIndex()
getUnconsumedMessagesCount()
→getUnreadMessagesCount()
getLastConsumedMessageIndex()
→getLastReadMessageIndex()
getLastConsumptionTimestamp()
→getLastReadTimestamp()
UpdateReason.LAST_CONSUMED_MESSAGE_INDEX
→UpdateReason.LAST_READ_MESSAGE_INDEX
UpdateReason.LAST_CONSUMED_MESSAGE_TIMESTAMP
→UpdateReason.LAST_READ_TIMESTAMP
CallbackListener
, StatusListener
and ProgressListener
are now interfaces (not abstract classes). Remove constructor invocation in Kotlin code to make it compile:
object : StatusListener() { … }
becomes
object : StatusListener { … }