2.x JavaScript Changelog
Getting Started? Go for Programmable Chat SDK 4.x for JavaScript
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.
Support for 2.x ceased 5/18/2019
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.
- Added method
Client.unsetPushRegistrationIdto deregister from push notifications - Added
lastMessagestructure toChannel - Added helper method
Client.getLocalChannelsto get (sorted) locally known channels, sorting is possible byuniqueName,friendlyName, orlastMessage
- Fixed re-using of
ClientOptionsbetween two clients creations in the same browser or node.js session - Various updates and fixes for documentation
- For
Messagewith typemediathebodyproperty now is null (instead of placeholder about unsupported media messaging) - Adjusting
Client#connectionStateChangedevent: addingdisconnectedanddisconnectingstates
- Fixed race in session initialization
- Various updates and fixes for documentation
This release is identical to 2.0.0. The sole purpose is to publish the new version to npmjs.com.
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.
Channel.addandChannel.joinfunctions will throw anSessionErrorin 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.advanceLastConsumedMessageIndexChannel.updateLastConsumedMessageIndexChannel.setAllMessagesConsumedChannel.setNoMessagesConsumed
ClientconstructorClient.initializefunction
Client.versionproperty now correctly displays Client's version- Fixed getting next page of Channel's User Descriptors after calling
Channel.getUserDescriptors
- Fixed incorrect handling of network timeouts in React Native
- Fixed session errors handling
- Added Multimedia Messaging (Public Beta) API (see * Media Support for more information) . Note Sending media messages on existing instances requires adding a new permission in your channel roles.
- In
Channel.sendMessagemethod you can provideFormData(for browsers) orSendMediaOptions(browsers and node.js apps) to send media from your client Messageclass is extended withtypeattributeMessageclass is extended withmediaattribute which holdsMediaclass instance- Role should contain Channel level
sendMediaMessagepermission for users to be able to send Media Messages
- Fixed a big in client creation which caused the operation to fail in rare cases
- Added
PushNotificationinterface for push notification representation - Added
Client#event:pushNotificationevent - Added static method
Client.parsePushNotificationto handle push payload and return thePushNotificationinstance back to client (intended use is Firebase service worker)
- Fixed unhandled promise rejections on new client creation in some rare cases
- SDK Reference Documentation fixes and updates
- Fixed additional issues related to Channel and ChannelDescriptor status updates not behaving as expected (which were not addressed in the 1.0.3 release)
- Fixed issues related to Channel status and uniqueName updates not behaving as expected
- SDK Reference Documentation fixes and updates
- Improvements made to the reliability of retrieval of Channel and User Descriptors
- 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
- 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.
- 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
messageRemovedevents 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
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.
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.
- Removed
Client.getPublicChannels()functionClient.getUserChannels()functionClient#event:userInfoUpdatedeventMember.userInfopropertyMember#event:userInfoUpdatedeventUserInfoclass
- Added
Channel.getUserDescriptors()functionChannelDescriptor.isPrivatepropertyChannelDescriptor.lastConsumedMessageIndexpropertyChannelDescriptor.statuspropertyChannelDescriptor.typepropertyClient.getPublicChannelDescriptors()functionClient.getSubscribedChannels()functionClient.getSubscribedUsers()functionClient.getUser(identity)functionClient.getUserChannelDescriptors()functionClient.getUserDescriptor(identity)functionClient#event:userSubscribedeventClient#event:userUnsubscribedeventClient#event:userUpdatedeventMember.getUser()functionMember.getUserDescriptor()function- new
Userclass - new
UserDescriptorclass
- Enable optimized UserInfo retrieval
- 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
channelAddedevent for public channels being joined was correctly fired again
- The
endpoint_ididentifier specified in access tokens is now automatically generated and persisted in the client browser cache. The following should be observed with this change:endpoint_idis no longer a required identifier in your generated access tokens, you may omit it from this build forwardendpoint_idwill be ignored if specified with your access token
- Added a
directionparameter to channel.getMessage method.backwardsis default direction to keep api compatible with previous versions
- Fixed a bug whereby the
anchorparameter in channel.getMessage method was incorrectly processed.
- Fixed an issue where sometimes a 404 error was returned when querying a channel for messages and members, when the channel was retrieved through
getChannelBySidandgetChannelByUniqueNamedirectly 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
- Constructor doesn't accept AccessManager interface anymore. Just token. Also user has to call client.updateToken himself when needed.
- Removed
client.identityproperty. Use client.userInfo.identity client.getUserChannelsis now paged and returns only channels which are related to the identity (statuses are: invited, joined, and private channels)client.getPublicChannelsreturns list of channelDescriptor, also in paged mannerchannel.getMessagesPagedis removedchannel.getMessages()returns paginator instead of array- Added counter methods: channel.getMessagesCount, channel.getUnreadMessagesCount, channel.getMembersCount
userInfo#updatedevent now also reports a name of a key which has been updated