|The Twilio Client SDKs for Android & iOS have been deprecated and replaced by Twilio's new Programmable Voice SDK. The Programmable Voice SDK offers many improvements over the Twilio Client SDK, including greater stability, improved backgrounding, and built-in support for push notifications for incoming calls.
Get started with the new Programmable Voice SDK by checking out one of the links below:
* Programmable Voice SDK for Android Quickstart
* Programmable Voice SDK for iOS: Objective-C Quickstart
* Programmable Voice SDK for iOS: Swift Quickstart
If you're just getting started with a Twilio mobile application for voice calling, we recommend you use the Programmable Voice SDK. If you're already using the Twilio Client SDK, you should plan to upgrade to the Programmable Voice SDK as soon as you're able.
Table Of Contents
The first thing we need to do is grab all the necessary information from our Twilio account. To set up our back-end for Twilio Client, we will need four values from our account:
|Account SID||Your primary Twilio account identifier - find this in the console here.|
|Auth Token||Used to authenticate - just like the above, you'll find this here.|
|TwiML App SID||The TwiML application with a voice URL configured to access your server running this app - create one in the console here. Also, you will need to configure the Voice "REQUEST URL" on the TwiML app once you've got your server up and running.|
|Twilio Phone #||A Twilio phone number in E.164 format - you can get one here|
Follow the instructions in the
README for each starter application to configure and run it on your machine, using the four values we created above:
Once you've got your server up and running, you will need to host it somewhere Twilio can access it. You can either publish your app with a web hosting provider, or you can run it locally and use something like ngrok to create a tunnel to your development machine with a publicly accessible URL.
See the README above for the specific ngrok instructions for your preferred platform.
Now, configure the Voice
REQUEST URL on your TwiML App to hit the voice URL on your server. (Again, see the README above for platform-specific instructions.)
This is where the fun begins! When you visit the homepage of the starter application, you should see a page which looks like this:
You have been assigned a random client name and are ready to make phone calls. You can type in a phone number to make a call, or you can type in the client name of another user. Try opening the web application in another browser window and call yourself. Echo...echo...echo.
While all of this is great (and we can use it to test the iOS app) - you're a mobile app developer, right? Let's get straight to some iOS code!
You will need XCode to run the starter iOS application, but you won't need your own iPhone or iPad - this app will also run on the simulator. Of course, running on your own device is more fun, and gives you better insight into how your final application will work in the real world.
We have two choices of client languages - Swift and Objective-C. If you're just getting started with iOS application development, we recommend starting with Swift.
You can also download the SDK and manually install the libraries and headers into your project.
One more thing you'll need to do before you run the application - you'll need to change the URL for capability tokens that the app uses to authorize itself with Twilio. This URL is going to be related to the server application you installed above - if you haven't done that step, and deployed the application to a web host or created an external URL with ngrok, go ahead and do that now.
After that, go ahead and find this constant,
DialViewController.m), and change it to your token location.
let TOKEN_URL = "https://asdf456.ngrok.io/token"
We've kept the iOS quickstart app pretty simple! All of the code you'll be interested in is in the
DialViewController class. After the view controller loads, we retrieve the capability token from your server, initialize a Twilio Client Device (TCDevice), and then wait for incoming connections (for instance, from the web app).
You can also connect to either a named client (like the web app), or a phone number (like your own)! Go ahead and call yourself from your app, it'll be fun!