Migration Guide: Android 0.11.0
Danger
Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
There are numerous breaking changes in the API that require you to update your apps, namely:
- rename to Chat
- removal of bundled AccessManager
- listener changes
- asynchronous methods
- deprecations
- removal of previously deprecated entities
- other changes in behavior
Package name has been changed from ip-messaging-android to chat-android .
- update your gradle imports to
compile "com.twilio:chat-android:0.11.0" - remove import of
twilio-common-androidif you had it previously
Namespace com.twilio.ipmessaging has been renamed to com.twilio.chat so update your imports.
Class IPMessagingClient has been renamed to ChatClient. A rename refactoring in Android Studio should handle that for you.
See commit c008f80d for details.
AccessManager is no longer bundled with the SDK by default, but you still need to provide some means of monitoring token expiration and updating the tokens if necessary.
If you have used AccessManager before and still have a need for it, you have an option to implement it yourself, or use Twilio-provided AccessManager package:
compile "com.twilio:accessmanager-android:0.1.0"
This version has slight differences from the previously packaged AM:
- namespace
com.twilio.commonhas been renamedcom.twilio.accessmanagerso update your imports tocom.twilio.accessmanager.AccessManager - this AM uses two different Listeners
AccessManager.Listenerfor listening to token expiration eventsAccessManager.TokenUpdateListenerfor listening to token update events
Now ChatClient.createClient() accepts only token itself. To update token on the already created client use ChatClient.updateToken(String) method.
The rest of the logic has remained the same. Details are in the documentation here.
Related twilio-chat-demo-android change: b48a9531
Listener callbacks will be called from the SDK on the originating thread (the one that called method with the listener) or on main UI thread - this depends on whether the calling thread has a Looper - then the originating thread Looper is used, otherwise the main application UI thread Looper is used and callback is dispatched on it. For the code used in callbacks, this means you no longer need to repost callback events to the main UI thread yourself. This change is reflected in the demo application commit 1f0ba938.
Some obsoleted listener types were removed - see below in deprecations list. In general, the generic CallbackListener<T> is preferred everywhere. See commit 0d22cbdf.
Almost the entire API has been reworked around asynchronous callback-oriented design. This lets SDK perform better when making networking requests to Twilio services and avoid blocking main UI thread unnecessarily.
See commit d5a34baa.
- Deprecated
ChatClient.Properties.setInitialMessagesCount(). See below for explanation. Code change is in commit bf2e8a3b.
- Removed previously deprecated
InitListener. Instead, use genericCallbackListener<Client>to receive client after construction. CreateChannelListeneris replaced with genericCallbackListener<Channel>. As a result, listeners'onCreate()method is renamedonSuccess(). See commit 0d22cbdf.
- Removed previously deprecated
TwilioIPMessagingSDK. Now all functionality previously provided by this SDK class is provided byChatClient. You do not need to call specialinitialiseSdkfunction anymore. When you're done working withChatClientinstance pleaseshutdown()it to reclaim resources and memory. You can create multipleChatClientinstances and use them in parallel. Constantsnamespace-class is removed from SDK,StatusListenerandCallbackListenerare now incom.twilio.chatnamespace. Constants themselves have been removed completely and are not used by the SDK. If you want to use them, see commit e0c98eab.
- Remove previously obsoleted
ChannelListener.onAttributesChange(). No replacement provided. Commit 92d6e94b. - Remove previously deprecated
Channels.createChannel()with attributes map. Instead, useChannels.channelBuilder(). See example in this file. - Remove previously deprecated
Messages.getMessages(). Use asynchronous methodsgetLastMessages,getMessagesBeforeandgetMessagesAfter.- The equivalent replacement for
Properties.setInitialMessagesCount(x)and then issuinggetMessages()isMessages.getLastMessages(x, listener)
- The equivalent replacement for
ChatClientListener.onChannelInvite(Channel) is added to the interface. You will receive this callback when you are invited to a channel. Commit cf28eb17.
Therefore, ChatClient.setIncomingIntent has been removed as well.
Old method with setIncomingIntent on IPMessagingClient and then parsing it - not supported anymore by the SDK; you could implement it yourself in the app if that's the way you handle the channel invites.
ChatClient has a shutdown() method which will call dispose() to free up memory and also leave ChatClient in an unusable state - many other SDK objects are also checking for disposed state now, so if your code accidentally was reusing objects from the previous ChatClient instance, you will be instantly notified - via IllegalStateException.
To control memory consumption call dispose() manually on objects that you will no longer use.