Programmable Chat Client SDKs

Twilio Programmable Chat provides client-side SDKs for browser-based web applications as well as for native iOS and Android applications.

JavaScript SDK

The latest version of the JavaScript SDK for Chat is available on Twilio's CDN. To include it on your web page, simply add the following script tag:

<script src="https://media.twiliocdn.com/sdk/js/common/v0.1/twilio-common.min.js"></script>
<script src="https://media.twiliocdn.com/sdk/js/chat/v3.0/twilio-chat.min.js"></script>

The Twilio.Chat and Twilio.Common namespaces should then be available in the window scope of your JavaScript application. Note that AccessManager, and thus Twilio Common, is optional for use with token lifecycle management.

The JS Programmable Chat SDK is also available from NPM (JS):

iOS SDK

The Programmable Chat SDK for iOS is available for integration using CocoaPods or a direct framework download. We also offer an optional component, Twilio AccessManager, which helps you manage your access token's expiry lifecycle using the same distribution options.

We ship dSYM files which can assist in crash reporting for versions of Programmable Chat for iOS 2.3.2 and above. You can read more about integrating these dSYM's in the documentation. If you use Fabric's Crashlytics in your application, you are encouraged to perform these additional steps when integrating Programmable Chat.

CocoaPods Integration

To install with Cocoapods, add the following to your Podfile, changing MyTarget to the name of your target:

source 'https://github.com/CocoaPods/Specs'

target 'MyTarget' do
  pod 'TwilioChatClient', '~> 2.3.0'
end

If you wish to use the optional AccessManager framework (for token lifecycle management, you will need to add the following pod target to your MyTarget block:

  pod 'TwilioAccessManager', '~> 1.0.0'

Carthage Integration

We support integration using Carthage binary frameworks. You can add Programmable Chat for iOS by adding the following line to your Cartfile:

github "twilio/twilio-chat-ios"

If you would like to integrate the optional Access Manager helper to manage your access token lifecycle as well, also add:

github "twilio/twilio-accessmanager-ios"

Then run carthage bootstrap (or carthage update if you are updating your SDKs.)

The .framework file(s) will be downloaded to the Carthage/Build/iOS directory. The final step is to complete integration below.

Direct Integration

We also offer the frameworks for direct download if your project is not using CocoaPods. There are several steps you'll need to complete to successfully add Programmable Chat to your project:

Upon expanding the .tar.gz file, you will find the .framework file(s) inside the directory created. The final step is to complete integration below.

Completing Framework Integration

These steps are done for you if you are using CocoaPods, but are required if using either Carthage or Direct integration.

Drag the .framework file(s) into your project, making sure they are dropped in the Embedded Binaries section of your project target's settings, selecting 'Copy items if needed' when prompted. If the framework files do not appear in the Embedded Binaries for your target, you will receive a "Reason: image not found" error during compilation.

On that same page, in the Linked Frameworks section, please also add libstdc++.tbd as a dependency to your target.

Our frameworks include both device and simulator versions of the SDK to ease integration at development time. The AppStore only supports device symbols at submission time, so you must remove the simulator symbols at export time, or you will receive an "Unsupported Architectures" error during app submission. We include a script to help with this inside the framework which your project can use during packaging:

  • Open your target's settings
  • Select Build Phases
  • Add a new Run Script phase, move it to below the Embed Frameworks step if it is not added there automatically
  • Set the command to run to: bash "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/TwilioChatClient.framework/remove_archs"

Please note - you will need to repeat this to add a remove_archs step for Twilio AccessManager if you are using it in your project as well.

Android SDK

The Android SDK is distributed as a direct download from Twilio's CDN. It can also be installed via Maven or directly within a Gradle build file via JCenter.

Direct CDN

JCenter

Maven

To install via Maven, please include the following in your POM file dependencies:

<dependency>
  <groupId>com.twilio</groupId>
  <artifactId>chat-android</artifactId>
  <version>3.1.0</version>
  <type>pom</type>
</dependency>

Note that if you wish to use the AccessManager convenience class, you will need to include the Maven dependency manually as follows:

<dependency>
  <groupId>com.twilio</groupId>
  <artifactId>accessmanager-android</artifactId>
  <version>0.1.0</version>
  <type>pom</type>
</dependency>

Gradle

To install via a Gradle build file, include the following in your Gradle build file:

allprojects {
    repositories {
        jcenter()
    }
}

/**
 * Declare dependencies
 * @see http://www.gradle.org/docs/current/userguide/userguide_single.html#sec:how_to_declare_your_dependencies
 */
dependencies {
    compile 'com.twilio:chat-android:3.1.0'
}

Note that if you wish to use AccessManager, you will need to add the following to your dependencies manually:

compile 'com.twilio:accessmanager-android:0.1.0'

Demo / Reference Client Applications

Core Chat SDKs

A demo client implementation for each of the SDKs exists and is available freely for reference purposes via GitHub. These are updated to use the latest SDK versions and implement almost all the available functionality.

JavaScript

https://github.com/twilio/twilio-chat-demo-js

iOS

https://github.com/twilio/twilio-chat-demo-ios

Android

https://github.com/twilio/twilio-chat-demo-android

Other SDKs/Tools

The additional 3rd party bindings and reference implementations below one of the core SDKs.

React Native

https://github.com/twilio/TwilioChatJsReactNative

Cordova

https://github.com/twilio/twilio-chat-js-cordova-example

Requires the following plugins:

https://github.com/twilio/cordova-plugin-twilio-common

https://github.com/twilio/cordova-plugin-twilio-chat

Web Console Client

With FCM pushes functional

https://github.com/twilio/twilio-chat-console-webapp.js

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.