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
twilio-common-androidif you had it previously
com.twilio.ipmessaging has been renamed to
com.twilio.chat so update your imports.
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:
This version has slight differences from the previously packaged AM:
com.twilio.commonhas been renamed
com.twilio.accessmanagerso update your imports to
AccessManager.Listenerfor listening to token expiration events
AccessManager.TokenUpdateListenerfor listening to token update events
ChatClient.createClient() accepts only token itself. To update token on the already created client use
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.
CreateChannelListeneris 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
initialiseSdkfunction any more. When you’re done working with
shutdown()it to reclaim resources and memory. You can create multiple
ChatClientinstances and use them in parallel.
Constantsnamespace-class is removed from SDK,
CallbackListenerare now in
com.twilio.chatnamespace. 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
Properties.setInitialMessagesCount(x)and then issuing
ChatClientListener.onChannelInvite(Channel) is added to the interface. You will receive this callback when you are invited to a channel. Commit cf28eb17.
ChatClient.setIncomingIntent have been removed as well.
Old method with
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
To control memory consumption call
dispose() manually on objects that you will no longer use.