Table of Contents

Build an Android chat app with Sendbird UIKit

Build an Android chat app with Sendbird UIKit

Reading Time: 5 mins Building Time: 10 mins

Note: The following getting started guide uses Sendbird UIKit, a set of rich, prebuilt UI components, which you can use to create a modern messenger experience in your app in under 10 minutes. Of course, you can also use the Sendbird Chat SDK with your own custom UI.

Send your first message

Start sending a message with Sendbird from scratch using Kotlin and the Sendbird UIKit. The client-side and server-side code builds a communication channel to send and receive a message.

To send your first message, you will need to achieve two milestones.

1. Create a Sendbird account and users in the Sendbird environment.
2. Import Sendbird UIKit dependencies and integrate the Sendbird UIKit SDK in your application.

This guide covers both steps in detail and is meant for developers of any level of proficiency so they can see how easy it is to send their first message in their application starting from scratch. Let’s get started!

Create a Sendbird Account

1. Sign up for a free Sendbird account
2. Create an account using your email id or `Continue with Google`
3. Setup your Organization by entering `Organization name` and `Phone number`
4. Create your Sendbird application after choosing `Product type`, and entering your `Application Name`, `Region`
5. You will be directed to the main page of the Sendbird Dashboard to get started with implementing Sendbird Chat SDK, API in your product.
6. Once you’re in copy your unique `applicationID` from the Application section and paste it in your clipboard

Create users in Sendbird Dashboard

1. Navigate to Users section in the left navigation of the dashboard
2. Click `Create user +` icon on the top right
3. Create a new user by filling out the following fields:
– `ID`
– `Nickname`
– `Profile URL` – Optional
– `Issue access token` – Optional

Create at least two users to begin with so you have users in your application that can chat with one another.

Add Sendbird UIKit SDK

To build our project we will be using Android Studio as our IDE, and creating a fresh project. Or you can add to an existing project with little difference to what will be covered below.

1. Create a project

  1. In the Welcome to Android Studio window, click Start a new Android Studio project.
  2. In the Select a Project Template window, select Empty Activity, and click Next.
  3. Enter your project name in the Name field in the Configure your project window.
  4. Select your language as either Java or Kotlin from the Language drop-down menu.
  5. Enable Use androidx.*artifacts.
  6. Select minimum API level as 16 or higher.

2. Install the UIKit using Gradle
1. The UIKit for Android is installed via Gradle. Add the following to the project level build.gradle file.

2. Then open your app level build.gradle file. For Java and Kotlin, add code blocks and dependencies as below and Sync to apply the changes.

Initialize the UIKit SDK

1. Create a class named BaseApplication, and initialize a SendBirdUIKit instance by passing the SendBirdUIKitAdapter instance as an argument to a parameter in the SendBirdUIkit.init() method.

  1. The SendBirdUIkit.init() must be called once in the onCreate() method of the Application instance of your client app.

  • Add the created BaseApplication to the AndroidManifest.xml

2. ChannelListActivity

  1. The ChannelListActivity is the starting point for launching our UIKit in your application. With just a single line of code the entirety of the UIKit can be implemented in your app.

Note: *You can launch the UIKit from either a Fragment or an Activity, and you do not need to extend ChannelListActivity.*

Test your integration

1. Run the application on a emulator or a plugged in device.
2. Go ahead and create a channel as shown below.

  1. Add any users you want.
  2. Click the create button

3. Send your first message

Try typing a message and hit send. You should be able to successfully send your first message in the newly built chat in your application.

 

Congratulations!

You are ready to send and receive messages with Sendbird.