Live iOS v1
Live iOS
Live
iOS
Home
/
Live
/
iOS

Authentication

You can start building a live streaming experience with chat by installing Sendbird Live SDK. Installing the Live SDK will also install Sendbird Chat SDK which provides the chat feature in the Live SDK.

Before using the features of Sendbird Live SDK for iOS, your application must initialize the SDK and authenticate a user and be connected with the Sendbird server. Then, the instance communicates and interacts with the server using an authenticated user account and the user can use the features in the Live SDK.


Authenticate to the Sendbird server

In order to use the Live SDK in the client app, initialize the SDK with your Sendbird application ID when you first launch the client app. You can find your application ID on Sendbird Dashboard.

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        SendbirdLive.initialize(applicationId: "APPLICATION_ID")
        ..
    }
}

Once you've authenticated the client app, authenticate a user by calling the SendbirdLive.authenticate() method. Calling this method also authenticates the user with Sendbird Chat SDK which provides the chat functionality during a live event.

func signIn(userId: String, accessToken: String?) {
    SendbirdLive.authenticate(userId: userId, accessToken: accessToken) { result in
        switch result {
        case .success(let user):
            // A user is successfully created.
        case .failure(let error):
            // Error occurred during authentication.
        }
    }
}

Deauthenticate from the Sendbird server

When the user no longer needs to use features from the Sendbird Live SDK, it is recommended to disconnect the user from the server. Calling this method also disconnects the user from the Sendbird Chat SDK as well.

SendbirdLive.deauthenticate {
    // User is successfully deauthenticated.
}