Menu

Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Migration Guide: Android 0.11.0

Breaking changes

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

Rename to (Programmable) Chat

This is rather simple part:

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-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.

Removal of AccessManager

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.common has been renamed com.twilio.accessmanager so update your imports to com.twilio.accessmanager.AccessManager
  • this AM uses two different Listeners
  • 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 changes

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.

Asynchronous methods

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.

Deprecations

  • Deprecated ChatClient.Properties.setInitialMessagesCount() . See below for explanation. Code change is in commit bf2e8a3b.

Removal of deprecated entities

Listeners

  • Removed previously deprecated 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.

Classes

  • Removed previously deprecated TwilioIPMessagingSDK . Now all functionality previously provided by this SDK class is provided by ChatClient . You do not need to call special initialiseSdk function any more. 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.

Methods

  • Remove previously obsoleted ChannelListener.onAttributesChange() . No replacement provided. Commit 92d6e94b.
  • Remove previously deprecated Channels.createChannel() with attributes map. Instead, use Channels.channelBuilder(). See example in this file.
  • Remove previously deprecated Messages.getMessages() . Use asynchronous methods getLastMessages , getMessagesBefore and getMessagesAfter .
  • The equivalent replacement for Properties.setInitialMessagesCount(x) and then issuing getMessages() is Messages.getLastMessages(x, listener)

Other behavioural changes

Channel invites logic changes

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 have 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.

dispose()

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.

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd browsing the Twilio tag on Stack Overflow.

Loading Code Sample...