Giter Site home page Giter Site logo

chat-quickstart-objc's Introduction

Chat iOS Quickstart for Objective-C

Looking for Swift instead? Check out this application.

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

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 four 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, and then fill in the account information you gathered above. 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.

Configure and Run the Mobile App

Our mobile application manages dependencies via Cocoapods. Once you have Cocoapods installed, download or clone this application project to your machine. To install all the necessary dependencies from Cocoapods, run:

pod install

Open up the project from the Terminal with:

open ChatQuickstart.xcworkspace

Note that you are opening the .xcworkspace file rather than the xcodeproj file, like all Cocoapods applications. You will need to open your project this way every time.

way every time.

You will need to go into ViewController.m and modify the URL for your Twilio Function there - each Twilio user will have a different domain to use for their Twilio Functions.

const NSString* kTokenURL =  @"https://YOUR_DOMAIN_HERE.twil.io/chat-token";

You should now be able to press play and run the project in the simulator.

Start sending yourself a few messages - they should start appearing in a UITableView in the starter app.

You're all set! From here, you can start building your own application. For guidance on integrating the iOS SDK into your existing project, head over to our install guide. If you'd like to learn more about how Chat works, you might want to dive into our user identity guide, which talks about the relationship between the mobile app and the server.

Good luck and have fun!

License

MIT

chat-quickstart-objc's People

Contributors

jefflinwood avatar kwhinnery avatar llsourcell avatar rbeiter avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.