Live UIKit iOS v1
Live UIKit iOS
Live UIKit
iOS
Version 1

Start your first live

Copy link

Sendbird Live UIKit is a set of prebuilt UI components that allows you to easily craft an in-app live stream with the essential streaming features including real-time chat. Our development kit includes UI components which you can customize to create an engaging live event experience for users.

Follow the guide below to start your live event with our easy-to-use UI components in Swift. If you would like to build using the Live SDK only, refer to Sendbird Live SDK.


Try Live Studio

Copy link

Live Studio is available on Sendbird Dashboard for you to try Sendbird Live in the quickest manner. You can use the Live Studio to test and demonstrate the functionalities to see what it's like to go live using Sendbird Live. Go to Sendbird Dashboard and create an application by selecting Calls+Live in product type and start Live Studio on the left navigation bar. Learn more about how to use it in this detailed blog post.


Requirements

Copy link

The minimum requirements for the Live UIKit for iOS are:

  • macOS
  • Xcode 15.0 and later
  • A device running iOS 12.0 and later
  • Swift 5.0 and later

Before you start

Copy link

Sendbird Live UIKit is an add-on to Sendbird Live SDK which provides live streaming feature and uses open channels for chat from Sendbird Chat SDK. Installing Sendbird Live UIKit will automatically install the Live SDK and the Chat SDK.

Before installing the Live UIKit, create a Sendbird account to acquire an application ID which you will need to initialize the Live UIKit. Go to Sendbird Dashboard and create an application by selecting Calls+Live in product type. Once you have created an application, go to Overview and you will see the Application ID.


Get Started

Copy link

You can start building your first live event by installing the Live UIKit. When you install the Live UIKit, Sendbird Live SDK will be installed implicitly.

Step 1 Create a project

Copy link

To get started, open Xcode and create a new project. The Live UIKit for iOS only supports Swift.

Step 2 Install the Live UIKit

Copy link

You can install the Live UIKit through either Swift Package Manager or CocoaPods. When you install the Live UIKit, its dependencies such as the Live SDK and the Chat SDK will be installed as well. The names of the framework and the main class in the Live UIKit and the Live SDK are SendbirdLiveUI and SendbirdLive, respectively.

Note: If you have already been using Sendbird Chat or want to know the minimum version of the Chat SDK to use the Live UIKit, you can check the information in Sendbird Live SDK repository.

Swift Packages

Copy link
  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:

https://github.com/sendbird/sendbird-live-uikit-ios
  1. To add the package, select Version Rules, enter Up to Next Major, 1.0.0, and click Next.

CocoaPods

Copy link
  1. Add SendBirdUIKit into your Podfile in Xcode as below:
platform :ios, '12.0'
use_frameworks!

target YOUR_PROJECT_TARGET do
    pod 'SendbirdLiveUIKit', '>= 1.0.0' // Add this line.
end
  1. Install the SendBirdUIKit framework through CocoaPods.
$ pod install
  1. Update the SendBirdUIKit framework through CocoaPods.
$ pod update

Step 3 Request permission to access camera and microphone

Copy link

Your users need to grant the client app the permission to access camera and microphone to stream media. They also need to allow the access to the photo library to send and download images and videos.

<key>NSPhotoLibraryUsageDescription</key>
    <string>$(PRODUCT_NAME) would like access to your photo library</string>
<key>NSCameraUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to access your camera</string>
<key>NSMicrophoneUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to access your microphone</string>
<key>NSPhotoLibraryAddUsageDescription</key>
    <string>$(PRODUCT_NAME) would like to save photos to your photo library</string>

Step 4 Initialize the Live UIKit

Copy link

To integrate the Live UIKit in the client app, you need to initialize it first. Initialize the SendbirdLiveUI instance by using the application ID of your Sendbird application, which can be found on Sendbird Dashboard.

// AppDelegate.swift

import SendbirdLiveUIKit

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    let APP_ID = "YOUR_APP_ID"    // Specify your Sendbird application ID.
    SendbirdLiveUI.initialize(applicationId: APP_ID) { // This is the origin.
        // Initialization of SendbirdUIKit has started.
        // Show a loading indicator.
    } migrationHandler: {
        // DB migration has started.
    } completionHandler: { error in
        // If DB migration is successful, proceed to the next step.
        // If DB migration fails, an error exists.
        // Hide the loading indicator.
    }
}

Step 5 Set current user

Copy link

Now that you have initialized the Live UIKit, you need to set a user to use the features of the Live UIKit. To do so, provide user information for currentUser in SBUGlobals. The userID field must be specified while other fields such as nickname and profileUrl are optional and will be filled with default values if not specified. You can either use information of a pre-existing user in your Sendbird application or create a new user.

When you use features of a view controller in the Live UIKit, the Live UIKit will automatically call the SendbirdLiveUI.connect() method to establish a connection with the server. You can also manually call the method to connect the user to the Sendbird server.

// AppDelegate.swift

import SendbirdUIKit

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

    // When only USER_ID is provided.
    SBUGlobals.currentUser = SBUUser(userId: {USER_ID})

    // When all fields are specified.
    SBUGlobals.currentUser = SBUUser(userId: {USER_ID}, nickname:{(opt)NICKNAME} profileUrl:{(opt)PROFILE_URL})

}

Step 6 Display a live event list

Copy link

Launch the Live UIKit in the client app with LiveEventListViewController, which serves as the starting point for using the Live UIKit to create, enter, and list live events. Implement the code below to start the Live UIKit wherever you would like in the client app.

import SendbirdLiveUIKit

let liveEventListVC = LiveEventListViewController()
let naviVC = UINavigationController(rootViewController: liveEventListVC)
self.present(naviVC, animated: true)

Step 7 Start your first live

Copy link

You can now run the app on a simulator or a plugged-in device. To start a live event, you must first create a live event by tapping the button in the top-right corner. Add a title, a cover image, and users who can be a host or else the default values will show. Once you have created a live event, tap on the live event to enter. You can choose to enter as a host or a participant and other users can enter the live event as participants.

You can also enter a live event manually as shown below.

liveEvent.enter { error in
    guard error == nil else { return }

    // User successfully entered the live event as a participant.
}

You've successfully started your first live event with Sendbird Live.