Home
/
UIKit
/
iOS

Send your first message

Sendbird UIKit for iOS is a set of prebuilt UI components that allows you to easily craft an in-app chat with all the essential messaging features. Our development kit includes light and dark themes, text fonts, colors and more. You can customize these components to create an interactive messaging interface unique to your brand identity.

Sendbird UIKit supports both open channels and group channels. Follow the guide below to start sending a message from scratch using Objective-C or Swift.

Three UIKit views on the Light theme are shown: list of channels, chat view, channel information view.


Requirements

The minimum requirements for UIKit for iOS are:

  • iOS 10.3 and later
  • Swift 4.2+ / Objective-C
  • Sendbird Chat SDK for iOS 3.0.226 and later

Get started

You can start building a modern messaging experience in your app by installing Sendbird UIKit. This developer kit is an add-on feature to Sendbird Chat SDK so installing it will also install the core Chat SDK. The minimum requirement of Chat SDK for iOS is 3.0.226 or later.

Step 1 Create a project

To get started, open Xcode and create a new project. Sendbird UIKit supports both objective-c and swift.

Setting up your project in the Create new project dialog.

Step 2 Install using CocoaPods

You can install UIKit for iOS through either CocoaPods, Carthage or Swift Package Manager. Skip to Step 3 if you wish to install using Carthage. Skip to Step 4 if you wish to install using Swift Package Manager.

  1. Add SendBirdUIKit into your Podfile in Xcode as below:
Light Color Skin
Copy
platform :ios, '10.3'
use_frameworks!

target YOUR_PROJECT_TARGET do
    pod 'SendBirdUIKit' // Add this line.
end
  1. Install the SendBirdUIKit framework through CocoaPods.
Light Color Skin
Copy
$ pod install
  1. Update the SendBirdUIKit framework through CocoaPods.
Light Color Skin
Copy
$ pod update

Step 3 Install using Carthage

Skip to Step 4 if you wish to install using Swift Package Manager.

  1. Add SendBirdUIKit and SendBirdSDK into your Cartfile as below:
Light Color Skin
Copy
github "sendbird/sendbird-uikit-ios"
github "sendbird/sendbird-ios-framework" == 3.0.226
  1. Install the SendBirdUIKit framework through Carthage.
Light Color Skin
Copy
$ carthage update --use-xcframeworks

Note: Building or creating the SendbirdUIKit framework with Carthage can only be done using the latest Swift. If your Swift is not the most recent version, the framework should be copied into your project manually.

  1. Go to your Xcode project target's General settings tab in the Frameworks and Libraries section. Then drag and drop on the disk of each framework from the <YOUR_XCODE_PROJECT_DIRECTORY>/Carthage/Build folder.

Note: Errors may occur if you're building your project with Xcode 11.3 or earlier versions. To fix these errors, refer to Handle errors caused by unknown attributes in the sample app.

Step 4 Install using Swift Package Manager

  1. Go to your Swift Package Manager's File tab and select Swift Packages. Then choose Add package dependency....

  2. Add SendBirdUIKit into your Package Repository as below:

Light Color Skin
Copy
github "sendbird/sendbird-uikit-ios"
  1. To add the package, select Up to Next Major Rules and click Next.

Step 5 Create a Sendbird application

A Sendbird application comprises everything required in a chat service including users, channels, and messages. To create an application:

  1. Go to Sendbird Dashboard and enter your email and password to create a new account. You can also sign up with a Google account.
  2. When prompted by the setup wizard, enter your organization information to manage Sendbird applications.
  3. Then when your dashboard home appears after completing the setup process, click Create + at the top-right corner.
  4. Once you've created a new application, go to Users and click Create user + at the top-right corner. This step is necessary in order to create a group channel and send a message.

Only one Sendbird application can be integrated per app for your service regardless of the platform. All users within your Sendbird application can communicate with each other across all platforms. This means that your iOS, Android and web client app users can send and receive messages with each other without any further setup. However, users in different Sendbird applications can't chat with each other as all data is limited to the scope of a single application.

Step 6 Initialize with APP_ID

To integrate and run Sendbird UIKit in your application, you need to initialize it first. Initialize the SendBirdUIKit instance through AppDelegate.

Objective-C
Swift
Light Color Skin
Copy
// AppDelegate.m

@import SendBirdUIKit;
...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...

    NSString *APP_ID = @"YOUR_APP_ID";  // Specify your Sendbird application ID.
    [SBUMain initializeWithApplicationId:APP_ID];
    ...

}
Light Color Skin
Copy
// AppDelegate.swift

import SendBirdUIKit
...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...

    let APP_ID = "YOUR_APP_ID"  // Specify your Sendbird application ID.
    SBUMain.initialize(applicationId: APP_ID)
    ...

}

Step 7 Set current user

User information must be set as CurrentUser in the SBUGlobals prior to launching Sendbird UIKit. This information will be used for various tasks within the kit, and if you don't set CurrentUser in advance, there will be restrictions in your usage. The userID field shown below must be specified. Other fields such as nickname and profileUrl are optional, and if not specified, they'll be filled with default values.

Set CurrentUser for UIKit through the AppDelegate as below:

Note: Even if you don't use AppDelegate, you should still register user information before launching a chat service.

Objective-C
Swift
Light Color Skin
Copy
// AppDelegate.m

@import SendBirdUIKit;
...

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    ...

    // Case 1: USER_ID only
    [SBUGlobals setCurrentUser:[[SBUUser alloc] initWithUserId:{USER_ID} nickname:nil profileUrl:nil]];

    // Case 2: Specify all fields
    [SBUGlobals setCurrentUser:[[SBUUser alloc] initWithUserId:{USER_ID} nickname:{(opt)NICKNAME} profileUrl:{(opt)PROFILE_URL}]];
    ...
}
Light Color Skin
Copy
// AppDelegate.swift

import SendBirdUIKit
...

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    ...

    // Case 1: USER_ID only
    SBUGlobals.CurrentUser = SBUUser(userId: {USER_ID})

    // Case 2: Specify all fields
    SBUGlobals.CurrentUser = SBUUser(userId: {USER_ID}, nickname:{(opt)NICKNAME} profileUrl:{(opt)PROFILE_URL})
    ...
}

Step 8 Display channel list

SBUChannelListViewController is the starting point for launching UIKit in your application. Implement the code below wherever you would like to start UIKit. You can see a complete list of group channels that you're a member of.

Objective-C
Swift
Light Color Skin
Copy
@import SendBirdUIKit;
...

SBUChannelListViewController *channelListVC = [[SBUChannelListViewController alloc] init];
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:channelListVC];
[self presentViewController:naviVC animated:YES completion:nil];

...
Light Color Skin
Copy
import SendBirdUIKit;
...

let channelListVC = SBUChannelListViewController()
let naviVC = UINavigationController(rootViewController: channelListVC)
self.present(naviVC, animated: true)

...

Note: If you are already using a navigation controller, you can use the pushViewController function.

Step 9 Send your first message

You can now run the application on a simulator or a plugged-in device. To send a message, you must first create a group channel by clicking on the icon in the top-right corner. Then, you can select users you wish to invite as members to your channel. Once the channel has been created, type your first message and press send.

Note: Sendbird UIKit offers features to attach or save files such as photos, videos, and documents in addition to sending text messages. To learn more about using those features, refer to Get attachment permission in the sample app.

You've successfully sent your first message with Sendbird.

Note: If you wish to distribute your application in the App store and remove unnecessary architectures in the application's build phase, go to Distribution settings in the sample app.


UIKit components

UIKit for iOS manages the lifecycle of its ViewController along with various views and data from the Chat SDK for iOS. UIKit components are as follows:


List of components

ComponentDescription

SBUChannelListViewController

A ViewController that manages a channel list.

SBUChannelViewController

A ViewController that manages a 1-on-1 chat channel.

SBUChannelSettingViewController

A ViewController that manages the channel settings.

SBUCreateChannelViewController

A ViewController that creates a channel.

SBUInviteUserViewController

A ViewController that invites a user to a channel.

SBUMemberListViewController

A ViewController that shows a list of members in a channel.

SBUTheme

A singleton that manages themes.

SBUColorSet

A singleton that manages color sets.

SBUFontSet

A singleton that manages font sets.

SBUMain

A class that contains static functions required when using Sendbird UIKit.

SBUGlobals

A class that contains static attributes required when using Sendbird UIKit.