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:
This is rather simple part:
Package name has been changed from ip-messaging-android
to chat-android
.
compile "com.twilio:chat-android:0.11.0"
twilio-common-android
if 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 simple 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:
com.twilio.common
has been renamed
com.twilio.accessmanager
so update your imports to
com.twilio.accessmanager.AccessManager
AccessManager.Listener
for listening to token expiration events
AccessManager.TokenUpdateListener
for 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.
ChatClient.Properties.setInitialMessagesCount()
. See below for explanation. Code change is in commit
bf2e8a3b
.
InitListener
. Instead, use generic
CallbackListener<Client>
to receive client after construction.
CreateChannelListener
is replaced with generic
CallbackListener<Channel>
. As a result, listeners'
onCreate()
method is renamed
onSuccess()
. See commit
0d22cbdf
.
TwilioIPMessagingSDK
. Now all functionality previously provided by this SDK class is provided by
ChatClient
. You do not need to call special
initialiseSdk
function anymore. When you're done working with
ChatClient
instance please
shutdown()
it to reclaim resources and memory. You can create multiple
ChatClient
instances and use them in parallel.
Constants
namespace-class is removed from SDK,
StatusListener
and
CallbackListener
are now in
com.twilio.chat
namespace. Constants themselves have been removed completely and are not used by the SDK. If you want to use them, see commit
e0c98eab
.
ChannelListener.onAttributesChange()
. No replacement provided. Commit
92d6e94b
.
Channels.createChannel()
with attributes map. Instead, use
Channels.channelBuilder()
. See example in
this file
.
Messages.getMessages()
. Use asynchronous methods getLastMessages
, getMessagesBefore
and getMessagesAfter
.
Properties.setInitialMessagesCount(x)
and then issuing
getMessages()
is
Messages.getLastMessages(x, listener)
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.