Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now

Menu

Expand
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?

Setting Up the Twilio Client

Making and receiving calls on your client devices, be they web browsers, iOS devices, or Android devices, requires the use of a Twilio Client SDK.

Get the SDK for your Platform

Currently, a Twilio Client SDK is available for JavaScript (for use in web-browsers and web-based apps), iOS, and Android.

JavaScript

Simply include the twilio.js library within the <head> of your HTML:

<script type="text/javascript"
src="//media.twiliocdn.com/sdk/js/client/v1.3/twilio.min.js"></script>

iOS

The easiest way to incorporate TwilioSDK to your iOS project is using CocoaPods. Simply add the following line to your Podfile:

source 'https://github.com/twilio/cocoapod-specs'

target 'MyTwilioApp' do
    pod 'TwilioClient', '~>1.2'
end

Alternatively, you may download the tar.bz2 file (80 MB).

Android

To install the latest Client SDK library add the following configuration to your build.gradle file:

allprojects {
  repositories {
     jcenter()
  }
}

dependencies {
  // The Client SDK resides on jCenter
  compile 'com.twilio:client-android:1.2.17'
}

Enable Microphone Permissions

In order to target Android API level 23 or later, you will need to ensure that your application requests runtime permissions for microphone access. To do this, perform the following two steps:

First, add the following to your Android Manifest file:

 <uses-permission android:name="android.permission.RECORD_AUDIO"/>

Second, request microphone permissions from within your application code:

ActivityCompat.requestPermissions(this,
    new String[]{Manifest.permission.RECORD_AUDIO}, MIC_PERMISSION_REQUEST_CODE);
}

See the Official Android Documentation for more details.

Client Service

The Client SDK utilizes an Android Service to maintain availability while your application is not in the foreground, the service must be declared in your AndroidManifest.xml

<service android:name="com.twilio.client.TwilioClientService" 
                       android:exported="false" android:stopWithTask="true"/>

ProGuard Exception

Add the following line to your proguard-project.txt file.

# Twilio Client
-keep class com.twilio.** { *; }

# Apache HttpClient
-dontwarn org.apache.http.**

This ensures that the Twilio Client library is not removed by ProGuard.

Get a Capability Token

In order to use Twilio Client, you need a Capability Token. An application server is required to generate these. The following sample shows how to request a token from your application server, assuming the /token URL is the correct URL at which to request a token.

        
        
        
        

        Create a Twilio.Device

        Think of a Device as a virtual phone. You create a Device so you can make and receive calls, hang up a call, etc. All you need to create a Device is your Capability Token, which we saw how to retrieve in the example above.

              
              
              
              

              For a full reference of what you can do with a Device, see the appropriate platform's SDK reference:

              For practical examples, refer to our Twilio Client guides:

              David Prothero Ricky Holtz
              Rate this page:

              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.