The best way to Combine Chat Options into Shopper Apps Through SendBird’s API


VoIP calls, real-time chat and messaging have turn into ubiquitous in enterprise for one cause: They work.

Shoppers have come to anticipate the power to immediately contact service suppliers. This type of communication can drive gross sales and result in higher buyer satisfaction. The draw back is that growing this type of performance in-house is commonly useful resource intensive. Moreover, it could not make sense for lots of firms amid the COVID-19 pandemic and a slumping financial system. Turning to an API for performance that you simply may in any other case have developed in home can save on growth prices whereas rushing the characteristic’s time to market.

On this article, we offer directions on tips on how to rapidly implement the Sendbird UIKit for iOS and deploy fully-featured messaging utilizing pre-built UI and messaging UX. Sendbird UIKit for iOS is basically a mix of person interface tooling and the Sendbird Chat SDK for iOS.

Getting began

Some issues to bear in mind. Sendbird UIKit for iOS is a growth equipment with a person interface that allows the combination of ordinary chat options into new or present shopper apps.

From the general theme to particular person kinds, corresponding to colours and fonts, elements might be totally custom-made for an organization’s model id.

At present, UIKit for iOS helps group channels solely, that’s channels with a number of folks in them. The minimal necessities are iOS 10.three+, Swift four.2+ / Goal-C and Sendbird Chat SDK for iOS For these wishing to check drive Sendbird’s pattern app, they will entry it from our GitHub repository.

Sendbird UIKit helps each Goal-C and Swift, so customers can create a mission within the language they need to develop with.

UIKit for iOS might be put in by both CocoaPods or Carthage:

For CocoaPods

Add SendBirdUIKit into your Podfile in Xcode as beneath:
platform :ios, ’10.three’

pod ‘SendBirdUIKit’
endInstall the SendBirdUIKit framework by CocoaPods.
$ pod installUpdate the SendBirdUIKit framework by CocoaPods.
$ pod replace

Word: The Sendbird UIKit for iOS is Sendbird Chat SDK-dependent. In the event you set up the UIKit, CocoaPods will routinely set up the Chat SDK for iOS as nicely. The minimal requirement of the Chat SDK for iOS is or larger.

For Carthage

Add SendBirdUIKit into your Cartfile as beneath:
github “sendbird/sendbird-uikit-ios”Set up the SendBirdUIKit framework by Carthage.
$ cartage replace Go to your Xcode mission goal’s Basic settings tab within the Frameworks and Libraries part. Then drag and drop on the disk every framework from the /Carthage/Construct/iOS folder.Go to your Xcode mission goal’s Construct Phases settings tab, click on the + icon, and select New Run Script Section. Create a Run Script, specify your shell (ex: /bin/sh), and add /usr/native/bin/carthage copy-frameworks to the script beneath the shell.

Media attachment permission

Sendbird UIKit gives options to connect or save recordsdata corresponding to pictures, movies, and paperwork. To make use of these options, you could request permission from finish customers.As soon as the permission is granted, customers can ship picture or video messages and save media property.

Subsequent, place the beneath code within the Data.plist file current within the root folder of your iOS mission. This can assist in creating in software notifications to request for permissions.

$(PRODUCT_NAME) would really like entry to your picture library
$(PRODUCT_NAME) wish to use your digicam
$(PRODUCT_NAME) wish to use your microphone (for movies)
$(PRODUCT_NAME) wish to save pictures to your picture library
Media attachment permission

(Elective) Doc attachment permission
If you wish to connect recordsdata from iCloud, you will need to activate the iCloud characteristic. As soon as it’s activated, customers can even ship a message with recordsdata from iCloud.

Go to your Xcode mission’s Signing & Capabilities tab. Then, click on + Functionality button and choose iCloud. Test iCloud Paperwork.

(Optional) Document attachment permission

Implementation information

Initialize with an APP_ID

In an effort to use the Chat SDK’s options, you will need to initialize the SendBirdUIKit occasion with an APP_ID. This step additionally initializes the Chat SDK for iOS. Initialize the SendBirdUIKit occasion by AppDelegate as proven by placing the code within the AppDelegate.m file:

// AppDelegate.m

@import SendBirdUIKit;

– (BOOL)software:(UIApplication *)software didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

NSString *APP_ID = @”2D7B4CDB-932F-4082-9B09-A1153792DC8D”; // The ID of the Sendbird software which UIKit pattern app makes use of..
[SBUMain initializeWithApplicationId:APP_ID];

Word : Within the above, it is best to specify the ID of your Sendbird software instead of the APP_ID.

Set the present person

Consumer info have to be set as CurrentUser within the SBUGlobal previous to launching the Sendbird UIKit. This info might be used inside the equipment for numerous duties. The userId subject have to be specified whereas different fields corresponding to nickname and profileUrl are elective and crammed with default values if not specified.

Set the CurrentUser for UIKit by the AppDelegate.m file as beneath:

Word: Even when you do not use the AppDelegate, it is best to register person info earlier than launching a chat service.

// AppDelegate.m
@import SendBirdUIKit;

– (BOOL)software:(UIApplication *)software didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

Word: If the CurrentUser is just not set prematurely, there might be restrictions to your utilization of the UIKit.

Channel record

UIKit lets you create a channel particularly for 1-on-1 chat and to record 1-on-1 chat channels so as to simply view and handle them. With the SBUChannelListViewController class, you’ll be able to present end-users with a whole chat service that includes a channel record.

Use the next code for the SceneDelegate and AppDelegate by placing it within the SceneDelegate.m and AppDelegate.m recordsdata respectively


// SceneDelegate.m
@import SendBirdUIKit;

– (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session choices:(UISceneConnectionOptions *)connectionOptions


// AppDelegate.m
@import SendBirdUIKit;

– (BOOL)software:(UIApplication *)software didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

SBUChannelListViewController *channelListVC = [[SBUChannelListViewController alloc] init];
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:channelListVC];
self.window.rootViewController = naviVC;

Word: At this level, you’ll be able to verify if the service is working by working your shopper app.


With the SBUChannelViewController class, you’ll be able to construct a channel-based chat service as a substitute of a channel list-based one. This code is used to open a chat between customers. For instance, if the person selects a chat icon in your software to speak with one other person, you should use the beneath code to current the chat. This eliminates the necessity to present a channel record within the app if the app developer doesn’t need to present a listing.

Word: It is best to have both a SBDChannel object or a ChannelUrl in an effort to run a channel-based chat service. You possibly can implement the code in AppDelegate.m or anyplace in your service the place you’d prefer to implement chat within the method said above. Use the next code to implement the chat service:


@import SendBirdUIKit;

SBUChannelViewController *channelVC = [[SBUChannelViewController alloc] initWithChannelUrl:];
UINavigationController *naviVC = [[UINavigationController alloc] initWithRootViewController:channelVC];
[self presentViewController:naviVC animated:YES completion:nil];

For Goal-C

UIKit is a Swift-based framework. Nevertheless, In case your mission is in Goal-C, configuring only a few extra steps lets you run the equipment in your shopper app. Go to your Xcode mission goal’s Construct settings tab after which set the ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES to YES.

Distribution setting

UIKit is distributed within the type of a fats binary, which incorporates info on each Simulator and System architectures. Add the script beneath if you’re planning to distribute your software within the App Retailer and want to take away pointless architectures within the software’s construct part.

Go to your Xcode mission goal’s Construct Phases tab. Then, click on + and choose New Run Script Section. Append this script.

# This script loops by the frameworks embedded within the software and
# removes unused architectures.
discover “$APP_PATH” -name ‘*.framework’ -type d | whereas learn -r FRAMEWORK
FRAMEWORK_EXECUTABLE_NAME=$(defaults learn “$FRAMEWORK/Data.plist” CFBundleExecutable)


for ARCH in $ARCHS

echo “Merging extracted architectures: $ARCHS”
lipo -o “$FRAMEWORK_EXECUTABLE_PATH-merged” -create “$”
rm “$”

echo “Changing authentic executable with thinned model”

UIKit at a look

The UIKit for iOS manages the lifecycle of its ViewController together with numerous views and information from the Chat SDK for iOS. UIKit Parts are as follows:

UIKit at a glance


In an effort to use the options of Sendbird UIKit for iOS in your shopper apps, a SendBirdUIKit occasion have to be initiated in every shopper app by person authentication with the Sendbird server.

The occasion communicates and interacts with the server utilizing an authenticated person account, and is allowed to make use of the UIKit’s options. This web page explains tips on how to authenticate your person with the server.

Set an entry token

Sendbird server authenticates requests from shopper apps by two strategies: One is utilizing solely person ID, the opposite is utilizing a person ID together with the person’s entry token.

The person ID authentication might be helpful for functions in growth or present companies the place extra safety is just not essentially wanted. However, the entry token authentication generates entry tokens for every person by the Chat Platform API.

When you request and procure a token for a person, you could use that particular entry token to authenticate the person. This goes within the AppDelegate.m file.


[SBUGlobals setAccessToken:];

Hook up with the Sendbird server

The SBUMain.join() technique connects a person to the Sendbird server utilizing the preset info of the CurrentUser. If the person ID used in the course of the connection try doesn’t exist on the Sendbird server, a brand new person account is created with the required person ID.

The SBUMain.join() technique additionally routinely updates the person profile on the Sendbird server.

When the ViewController is known as within the UIKit, the connection is routinely made with the CurrentUser info which was set within the SBUGlobal.

In case you need to connect with the Sendbird server at a selected timing, you should use the code as beneath. This goes within the AppDelegate.m file:

[SBUMain connectWithCompletionHandler:^(SBDUser * _Nullable user, SBDError * _Nullable error) ];

Disconnect from the Sendbird server

When a person does not must obtain messages from the Sendbird server, it is suggested to disconnect the person from the server. Even after disconnected, the person can nonetheless obtain push notifications for brand spanking new messages delivered by APNs (Apple Push Notification Service). To implement this, please put this code within the AppDelegate.m file:

[SBUMain disconnectWithCompletionHandler:^];

Register for push notifications

Push notifications are a sort of notification despatched to your customers’ gadgets when an software is working within the background.

Push notifications for iOS functions will include a payload created by Sendbird and be delivered by APNs. The Sendbird server will talk with APNs every time wanted and APNs will ship a push notification to the applying on iOS gadgets.

In an effort to use this characteristic, you could register the system tokens of your shopper app customers to Sendbird server by the AppDelegate.m file.

Word: APNs needs to be arrange prematurely in an effort to ship push notifications.

– (void)software:(UIApplication *)software didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken

Word: You should use these strategies when the SBUGlobal.CurrentUser is about and linked to the Sendbird server.

Unregister for push notifications

It is best to unregister a person’s system tokens from the Sendbird server when you do not need to ship push notifications to the person. This could solely be used when you do not need to obtain push notifications anymore. To implement this, please use the beneath code within the AppDelegate.m file:

// If you wish to unregister the present system solely, name this technique.
[SBUMain unregisterPushTokenWithcompletionHandler:^(BOOL success) ];
// If you wish to unregister all gadgets of the person, name this technique.
[SBUMain unregisterAllPushTokenWithcompletionHandler:^(BOOL success) ];

Word: You should use these strategies when the SBUGlobal.CurrentUser is about and linked to the Sendbird server.

Replace person profile

When a CurrentUser is created with a novel ID of the person, the UIKit routinely generates the nickname and profileImage of the person based mostly on the required userId. You may as well modify these properties by your self when wanted within the AppDelegate.m file.

Word: You should use this technique when the SBUGlobal.CurrentUser is about and linked to the Sendbird server.

[SBUMain updateUserInfoWithNickname: profileUrl:PROFILE_URL completionHandler:^(SBDError * _Nullable) ];

Now that you’ve got achieved a little bit of success with the Sendbird API, you’ll be able to take into consideration the number of use circumstances it is likely to be helpful to. For instance, converstaional ecommerce functions to assist scale back purchaser uncertainty, in-app chat throughout stay streaming occasions to extend viewers engagement, or permitting a web-based cash switch by a chat interface as a substitute of requiring a financial institution buyer to go to a department.