Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

Migration Guide: Android 0.11.0


(error)

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(link takes you to an external page).

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.


Breaking changes

breaking-changes page anchor

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

rename-to-programmable-chat page anchor

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(link takes you to an external page) for details.


Removal of AccessManager

removal-of-accessmanager page anchor

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(link takes you to an external page).

Related twilio-chat-demo-android change: b48a9531(link takes you to an external page)


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(link takes you to an external page).

Some obsoleted listener types were removed - see below in deprecations list. In general, the generic CallbackListener<T> is preferred everywhere. See commit 0d22cbdf(link takes you to an external page).


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(link takes you to an external page).



Removal of deprecated entities

removal-of-deprecated-entities page anchor

Listeners

listeners page anchor
  • 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(link takes you to an external page) .
  • 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 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(link takes you to an external page) .
  • Remove previously obsoleted ChannelListener.onAttributesChange() . No replacement provided. Commit 92d6e94b(link takes you to an external page) .
  • Remove previously deprecated Channels.createChannel() with attributes map. Instead, use Channels.channelBuilder() . See example in this file(link takes you to an external page) .
  • 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

other-behavioural-changes page anchor

Channel invites logic changes

channel-invites-logic-changes page anchor

ChatClientListener.onChannelInvite(Channel) is added to the interface. You will receive this callback when you are invited to a channel. Commit cf28eb17(link takes you to an external page).

Therefore, ChatClient.setIncomingIntent has been removed as well(link takes you to an external page).

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.


Rate this page: