All Projects → TwilioDevEd → twiliochat-android

TwilioDevEd / twiliochat-android

Licence: MIT license
Android implementation of Twilio Chat

Programming Languages

java
68154 projects - #9 most used programming language
Twilio

Important Notice

We intend to sunset the Programmable Chat API on July 25, 2022 to focus on the next generation of chat: the Twilio Conversations API. Find out about the EOL process. We have also prepared this Migration Guide to assist in the transition from Chat to Conversations.

Twilio chat - Android

Build Status

Learn to implement a simple chat application using Twilio Programmable Chat Client

Read the full tutorial here!

Local development

  1. Clone the repository.
$ git clone https://github.com/TwilioDevEd/twiliochat-android.git
$ cd twiliochat-android
  1. This application was developed using Android Studio. So if you are using a different tool like Eclipse with ADT, there might be some additional steps you need to follow. If you are using Android Studio just open the project using the IDE.

  2. Twilio's Programmable Chat Client requires an access token generated using your Twilio credentials in order to connect. First we need to setup a server that will generate this token for the mobile application to use. We have created web versions of Twilio Chat, you can use any of these applications to generate the token that this mobile app requires, just pick you favorite flavor:

    Look for instructions on how to setup these servers in any of the links above.

  3. Once you have the server running (from the previous step), you need to edit one file in this android application.

    ProjectRoot(app) -> res -> values -> keys.xml (on the Android Studio)
    or
    ProjectRoot/app/src/main/res/values/keys.xml (on the file system)
    

    This file contains the token_url key. The default values is http://10.0.2.2:8000/token. This address refers to the host machine loopback interface (127.0.0.1) when running this application in the android emulator. You must change this value to match the address of your server running the token generation application. We are using the PHP - Laravel version in this case, that's why we use port 8000.

    Note: In some operating systems you need to specify the address for the development server when you run the Laravel application, here's an example:

    $ php artisan serve --host=127.0.0.1
    
  4. Now Twilio Chat is ready to go. Run the application on the android emulator or your own device. Make sure that you have properly set up the token generation server and the token_url key. To run the application in a real device you'll need to expose your local token generation server by manually forwarding ports, or using a tool like ngrok. If you decide to work with ngrok, your keys.xml file should hold a key like the following:

    <string name="token_url">"http://<your_subdomain>.ngrok.io/token"</string>
    

    No need to specify the port in this url, as ngrok will forward the request to the specified port.

Meta

  • No warranty expressed or implied. Software is as is. Diggity.
  • MIT License
  • Lovingly crafted by Twilio Developer Education.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].