Table of Contents

Build an iOS chat app with Sendbird UIKit

Build an iOS chat app with Sendbird UIKit

Janna Mclaughlin
Solution Engineer
Tutorial Type: Getting Started Reading Time: 5 mins Building Time: 10 mins
ChatiOSUIKit

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 iOS and the Sendbird UIKit SDK. 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. Integrate the Sendbird UIKit SDK into 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.

Create a Sendbird account

2. Create an account using your email or Continue with Google.
3. Set up your Organization by entering Organization name and Phone number.

Set up your organization - Sendbird dashboard

4. Create your Sendbird application after choosing Product type, and entering your Application Name, Region.

Create your Sendbird application

Create your Sendbird application

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 Application ID from the Application section and paste it into your clipboard.

Create users in Sendbird Dashboard

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
Create users in Sendbird account
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

We will use Xcode to create a new Swift application and add in the Sendbird UIKit SDK using CocoaPods.

Alternatively, you can create an Objective-C application to use with Sendbird UIKit. You can also [install the Sendbird UIKit SDK with Carthage by following these installation steps.

1. Create your app in Xcode

Open Xcode > click Create a new Xcode project > select App

Create your app in xcode

Name your project and specify your organization information as needed. To follow this example, name the app SendBirdApplication

Choose the directory where you want to save your app and click Create. Your app has been created and your Xcode project is now open. Xcode automatically created some important project files for you such as AppDelegate.swift and SceneDelegate.swift that we will use later.

2. Install UIKit for iOS using CocoaPods

In your Mac Terminal application, navigate to the project directory that has your new Xcode project in it (SendBirdApplication.xcodeproj).
To find this directory easily, select your project in Xcode and copy the Full Path and paste it into Terminal.

You should see the following files in this directory.

In Terminal, create your Podfile and open it.

Add SendBirdUIKit into your Podfile in Xcode as below and save.

Back in Terminal, install the SendBirdUIKit framework through CocoaPods. You should see the download and installation happening and a recommendation to use the Xcoe workspace file going forward. Your directory now has the Pods folder and the following files: Podfile, Podfile.lock, SendBirdApplication.xcworkspace.

If needed, update the SendBirdUIKit framework through CocoaPods. Check that you have the latest version of the SendBirdUIKit on GitHub.

3. Open the SendBirdApplication.xcworkspace file to continue in Xcode.

In Xcode, your application should now have the Pods folder and project inside of it.

Connect Sendbird UIKit to your application

1. Connect Sendbird UIKit to your application and create a user.

In the SendBirdApplication.xcworkspace in Xcode, add the Application ID of the Sendbird application you created earlier in the dashboard to initialize the Sendbird Chat SDK in the AppDelegate class.

– i.e. your Application ID will look similar to this: 45612F31-4304-4FC4-9FD9-C35B5FCDCE30

Set the CurrentUser for UIKit through the AppDelegate as below. User information must be set as CurrentUser in the SBUGlobal prior to launching Sendbird UIKit.

2. Load the channel list.

UIKit allows you to create a channel specifically for 1-on-1 chat and to list 1-on-1 chat channels so that you can easily view and manage them. With the SBUChannelListViewController class, you can provide end-users with a complete chat service featuring a channel list.

Add the following code into the AppDelegate class application(_:didFinishLaunchingWithOptions:) method and the SceneDelegate class scene(_:willConnectTo:options:) method.

The AppDelegate and SceneDelegate classes should now look as follows.

Test your integration

1. Run your app in Xcode by clicking the Play icon at the top.

Test your integration - Sendbird

Your app should now build and run in the iPhone Simulator or on your iOS device.

2. Create a channel and invite users to it.
You can now create a channel for users to chat in your application. Click the “+” icon at the top right of the view to create a new group channel and invite users.

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 in your application with Sendbird UIKit.

For additional information on Sendbird UIKit for iOS, check out our iOS docs.

That’s how easy it is to get chat up and running in your application. If you’re not building in JS,  get started with sending your first message with Sendbird UIKit for Android and JavaScript.

We’re rooting for you as you build something great.

Happy chat building!