Chat UIKit Jetpack Compose v3
Chat UIKit Jetpack Compose
Chat UIKit
Jetpack Compose
Version 3

Authentication

Copy link

In order to use the features of Sendbird UIKit for Jetpack Compose in your client apps, a SendbirdUIKitCompose instance must be initiated in each client app through user authentication with Sendbird server. The instance communicates and interacts with the server using an authenticated user account, and is allowed to use the UIKit's features. This page explains how to authenticate your user with the server.

Prerequisites

Copy link
  • Sendbird UIKit should be initialized, for the details please refer Getting Started.

Overview

Copy link

Authentication is required to use Sendbird’s features. There are three ways to authenticate:

  1. Guest Login: A token is not required. However, this method is not recommended for production due to security vulnerabilities. You use a UserID only to authenticate.
  2. Access Token: A token that does not expire. It can be generated by API or from the Dashboard.
  3. Session Token: Highly recommended for enhanced security.
    • Note: This document does not cover session handling. Please refer to this SDK document for more details.

In UIKit, the basic way to authenticate is as follows:

  1. Set and store a UserID and token.
  2. When accessing a screen, UIKit communicates with the Sendbird server using those credentials. This means UIKit handles authentication internally and automatically.

How You Can Set the User ID and Token

Copy link
SendbirdUikitCompose.prepare(
    UikitCurrentUserInfo(
        userId = userId,
        authToken = authToken
    )
)

Manual Connection

Copy link

You can manually connect to the Sendbird server and retrieve user information without accessing UIKit’s screens. This is commonly required when you need to call SDK functions outside of UIKit’s screens.

Example Use Case

Copy link

One example is registering a push token when a user logs into your service. To ensure notifications from Sendbird are not missed, you need to register the push token at the time of service login.

SendbirdUikitCompose.connect()
SendbirdPushHelper.registerHandler(MyFirebaseMessagingService())

Logout, Disconnect

Copy link

Call the SendbirdUIKitCompose.disconnect() method if the user requests to log out. If a user has been logged out and thus disconnected from the server, they will no longer receive messages.

NOTE: You must call unregisterPushToken to ensure the user does not receive notifications anymore.

SendbirdPushHelper.awaitUnregisterHandler()
SendbirdUikitCompose.disconnect()