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?

iOS Quickstart

In this guide, we will get you up and running quickly with a sample application you can build on as you learn more about Programmable Chat. Sound like a plan? Then let's get cracking!

Table Of Contents

Gather account information

The first thing we need to do is grab all the necessary configuration values from our Twilio account. To set up our back-end for Chat, we will need five pieces of information:

Config Value Description
Service Instance SID Like a database for your Chat data - generate one in the console here
Account SID Your primary Twilio account identifier - find this in the console here.
API Key Used to authenticate - generate one here.
API Secret Used to authenticate - just like the above, you'll get one here.
Mobile Push Credential SID Used to send notifications from Chat to your app - create one in the console here or learn more about Chat Push Notifications in iOS.

Create a Twilio Function

When you build your application with Twilio Chat, you will need two pieces - the client (this iOS app) and a server that returns access tokens. If you don't want to set up your own server, you can use Twilio Functions to easily create this part of your solution.

If you haven't used Twilio Functions before, it's pretty easy - Functions are a way to run your Node.js code in Twilio's environment. You can create new functions on the Twilio Console's Manage Functions Page.

You will need to choose the "Programmable Chat Access Token" template:

Twilio Functions Chat Access Token Template

Select the Programmable Chat Token template and click Create on the above dialog box, and then fill in the account information you gathered above on the next screen.

Chat Access Token Function Credentials

After you do that, the Function will appear, and you can read through it. Save it, and it will immediately be published at the URL provided - go ahead and put that URL into a web browser, and you should see a token being returned from your Function. If you are getting an error, check to make sure that all of your account information is properly defined.

Want to learn more about the code in the Function template, or want to write your own server code? Checkout the Twilio Chat Identity Guide for the underlying concepts.

Now that the Twilio Function is set up, let's get the starter iOS app up and running.

NOTE: You should not use Twilio Functions to generate access tokens for your app in production. Each function has a publicly accessible URL which a malicious actor could use to obtain tokens for your app and abuse them.

Read more about access tokens here to learn how to generate access tokens in your own C#, Java, Node.js, PHP, Python, or Ruby application.

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.