# 2.x JavaScript Changelog

> \[!NOTE]
>
> If you are starting out with Twilio's Programmable Chat SDK for JavaScript, we highly recommend starting with version 4.x. Version 4.x is our latest SDK and it brings many new features and improvements to the 1.x and 2.x versions. And it will be much easier to [migrate to Twilio Conversations](/docs/conversations/migrating-chat-conversations).

> \[!WARNING]
>
> **Not using 4.x? You should migrate ASAP**
>
> If you are already using 2.x, we highly recommend planning your migration to 4.x as soon as possible.
>
> **End-of-Life for 1.x occurred on June 30, 2019.**

### Programmable Chat 2.2.0 *(March 13, 2018)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/2.2.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/2.2.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/2.2.0/docs/)

#### Changes

* Added method `Client.unsetPushRegistrationId` to deregister from push notifications
* Added `lastMessage` structure to `Channel`
* Added helper method `Client.getLocalChannels` to get (sorted) locally known channels, sorting is possible by `uniqueName`, `friendlyName`, or `lastMessage`

#### Bug Fixes

* Fixed re-using of `ClientOptions` between two clients creations in the same browser or node.js session
* Various updates and fixes for documentation

### Programmable Chat 2.1.0 *(January 15, 2018)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/2.1.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/2.1.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/2.1.0/docs/)

#### Changes \[#changes-2]

* For `Message` with type `media` the `body` property now is null (instead of placeholder about unsupported media messaging)
* Adjusting `Client#connectionStateChanged` event: adding `disconnected` and `disconnecting` states

#### Bug Fixes \[#bug-fixes-2]

* Fixed race in session initialization
* Various updates and fixes for documentation

### Programmable Chat 2.0.1 *(December 19, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.1/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.1/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.1/docs/)

#### Overview

This release is identical to 2.0.0. The sole purpose is to publish the new version to `npmjs.com`.

### Programmable Chat 2.0.0 *(December 1, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/2.0.0/docs/)

#### Overview \[#overview-2]

Removed deprecated `Client` constructor and `Client.initialize` function, the correct way now is to use static function `Client.create`.
Behavioral breaking change in adding Member and joining Channel, now if User is already in the Channel, then `Channel.add` and `Channel.join` will throw `SessionError`. Changed function signature in Consumption Horizon functions, after successful setting of last message consumed these functions returns unread messages count in given Channel for logged in User.

#### Breaking Changes

* `Channel.add` and `Channel.join` functions will throw an `SessionError` in case of User already exists in the Channel
* Consumption horizon functions now returns `Promise<number>` with count of unread messages in the channel after the operation:
  * `Channel.advanceLastConsumedMessageIndex`
  * `Channel.updateLastConsumedMessageIndex`
  * `Channel.setAllMessagesConsumed`
  * `Channel.setNoMessagesConsumed`

#### Removed deprecated functions

* `Client` constructor
* `Client.initialize` function

#### Bug Fixes \[#bug-fixes-3]

* `Client.version` property now correctly displays Client's version
* Fixed getting next page of Channel's User Descriptors after calling `Channel.getUserDescriptors`

### Programmable Chat 1.2.1 *(October 12, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.1/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.1/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.1/docs/)

#### Bug Fixes \[#bug-fixes-4]

* Fixed incorrect handling of network timeouts in React Native
* Fixed session errors handling

### Programmable Chat 1.2.0 *(September 18, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.2.0/docs/)

#### New Features

* Added Multimedia Messaging (Public Beta) API (see \* [Media Support](/docs/chat/media-support) for more information) . **Note** Sending media messages on existing instances requires [adding a new permission in your channel roles](/docs/chat/media-support#required-role-permission).
* In `Channel.sendMessage` method you can provide `FormData` (for browsers) or `SendMediaOptions` (browsers and node.js apps) to send media from your client
* `Message` class is extended with `type` attribute
* `Message` class is extended with `media` attribute which holds `Media` class instance
* Role should contain Channel level `sendMediaMessage` permission for users to be able to send Media Messages

### Programmable Chat 1.1.2 *(August 22, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.2/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.2/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.2/docs/)

#### Bug Fixes \[#bug-fixes-5]

* Fixed a big in client creation which caused the operation to fail in rare cases

### Programmable Chat 1.1.1 *(August 16, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.1/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.1/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.1.1/docs/)

#### Changes \[#changes-3]

* Added `PushNotification` interface for push notification representation
* Added `Client#event:pushNotification` event
* Added static method `Client.parsePushNotification` to handle push payload and return the `PushNotification` instance back to client (intended use is Firebase service worker)

#### Bug Fixes \[#bug-fixes-6]

* Fixed unhandled promise rejections on new client creation in some rare cases
* SDK Reference Documentation fixes and updates

### Programmable Chat 1.0.4 *(July 14, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.4/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.4/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.4/docs/)

#### Bug Fixes \[#bug-fixes-7]

* Fixed additional issues related to Channel and ChannelDescriptor status updates not behaving as expected (which were not addressed in the 1.0.3 release)

### Programmable Chat 1.0.3 *(July 12, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.3/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.3/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.3/docs/)

#### Bug Fixes \[#bug-fixes-8]

* Fixed issues related to Channel status and uniqueName updates not behaving as expected
* SDK Reference Documentation fixes and updates

### Programmable Chat 1.0.2 *(July 4, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.2/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.2/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.2/docs/)

#### Changes \[#changes-4]

* Improvements made to the reliability of retrieval of Channel and User Descriptors

#### Bug Fixes \[#bug-fixes-9]

* Fix for clients with identities containing spaces / pluses / etc. during fetching Channel Descriptors
* Fix for object properties accessors in User, Member, Channel, Message
* Documentation fixes

### Programmable Chat 1.0.1 *(May 19, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.1/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.1/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.1/docs/)

#### Changes \[#changes-5]

* Added a new Factory method for creating the SDK Chat Client instance, specifically to avoid issues caused by using client that was created but not fully initialized. Note that the old manual constructor has been marked as `deprecated`.

#### Bug Fixes \[#bug-fixes-10]

* Fixed a rare issue whereby the client did not correctly initialize. This caused the typing indicator feature not to work correctly
* Fixed an issue whereby `messageRemoved` events were not correctly firing for messages that present at client init (i.e. not added after client init)
* The JS library should now be React Native friendly
* Various Documentation fixes

### Programmable Chat 1.0.0 *(May 2, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/1.0.0/docs/)

With this release, Programmable Chat is now in GA. A number of breaking changes were introduced as part of the GA release. To see what has changed and to migrate from the latest Public Beta SDK to the new GA SDK, please read the \* [GA Migration Guide for JavaScript](/docs/chat/javascript/sdk-migration-guide-js-10).

#### Overview \[#overview-3]

Client initialization has been simplified to reflect most users typical usage of the system. All user channels (channels for which the current user is joined to or an owner of) will be subscribed to from client startup but only the members roster will be synchronized initially. This keeps client startup fast while still reflecting the latest activity immediately to the client.

`UserInfo` has been deprecated and replaced with two distinct classed, `User` and `UserDescriptor`. Similar to `ChannelDescriptor` class, a `UserDescriptor` represents a snapshot of data in time that should be utilized directly after obtaining it but not retained since it will not be updated with new data over time.

Users are no longer implicitly subscribed to improve performance on large instances. You can subscribe up to a maximum 100 of users at once after which your least recently subscribed User will be unsubscribed.

#### Changes \[#changes-6]

* Removed
  * `Client.getPublicChannels()` function
  * `Client.getUserChannels()` function
  * `Client#event:userInfoUpdated` event
  * `Member.userInfo` property
  * `Member#event:userInfoUpdated` event
  * `UserInfo` class
* Added
  * `Channel.getUserDescriptors()` function
  * `ChannelDescriptor.isPrivate` property
  * `ChannelDescriptor.lastConsumedMessageIndex` property
  * `ChannelDescriptor.status` property
  * `ChannelDescriptor.type` property
  * `Client.getPublicChannelDescriptors()` function
  * `Client.getSubscribedChannels()` function
  * `Client.getSubscribedUsers()` function
  * `Client.getUser(identity)` function
  * `Client.getUserChannelDescriptors()` function
  * `Client.getUserDescriptor(identity)` function
  * `Client#event:userSubscribed` event
  * `Client#event:userUnsubscribed` event
  * `Client#event:userUpdated` event
  * `Member.getUser()` function
  * `Member.getUserDescriptor()` function
  * new `User` class
  * new `UserDescriptor` class

### Programmable Chat 0.13.0 *(March 30, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/0.13.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/0.13.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/0.13.0/docs/)

#### Changelog

* Enable optimized UserInfo retrieval

#### Bug Fixes \[#bug-fixes-11]

* Fixed a bug whereby a Client init race condition caused issues in some browsers (EDGE and other browsers more rarely)
* Ensure callbacks will arrive for channel left (fixed a race)
* Fixed an issue whereby leaving and rejoining a channel caused events to not be received after the rejoin
* Fixed an issue so that the `channelAdded` event for public channels being joined was correctly fired again

### Programmable Chat 0.12.0 *(February 23, 2017)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/0.12.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/0.12.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/0.12.0/docs/)

#### Changes \[#changes-7]

* The `endpoint_id` identifier specified in access tokens is now automatically generated and persisted in the client browser cache. The following should be observed with this change:
  * `endpoint_id` is no longer a required identifier in your generated access tokens, you may omit it from this build forward
  * `endpoint_id` will be ignored if specified with your access token
* Added a `direction` parameter to channel.getMessage method. `backwards`is default direction to keep api compatible with previous versions

#### Bug Fixes \[#bug-fixes-12]

* Fixed a bug whereby the `anchor` parameter in channel.getMessage method was incorrectly processed.

### Programmable Chat 0.11.1 *(December 7, 2016)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.1/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.1/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.1/docs/)

#### Bug Fixes \[#bug-fixes-13]

* Fixed an issue where sometimes a 404 error was returned when querying a channel for messages and members, when the channel was retrieved through `getChannelBySid` and `getChannelByUniqueName` directly after the client start
* Fixed an issue where the client sometimes failed to successfully start with a subscription setup error
* Fixed an issue where under certain conditions, the incorrect connection state was for the client instance

### Programmable Chat 0.11.0 *(November 21, 2016)*

* [js](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.0/twilio-chat.js)
* [min](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.0/twilio-chat.min.js)
* [docs](https://media.twiliocdn.com/sdk/js/chat/releases/0.11.0/docs/)

#### Changes \[#changes-8]

* Constructor doesn't accept AccessManager interface anymore. Just
  token. Also user has to call client.updateToken himself when needed.
* Removed `client.identity` property. Use client.userInfo.identity
* `client.getUserChannels` is now paged and returns only channels which
  are related to the identity (statuses are: invited, joined, and
  private channels)
* `client.getPublicChannels` returns list of channelDescriptor, also in
  paged manner
* `channel.getMessagesPaged` is removed
* `channel.getMessages()` returns paginator instead of array
* Added counter methods: channel.getMessagesCount,
  channel.getUnreadMessagesCount, channel.getMembersCount
* `userInfo#updated` event now also reports a name of a key which has been updated
