Android
UIKit Authentication

Authentication

In order to use the features of Sendbird UIKit for Android in your client apps, a SendBirdUIKit 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.


Connect to Sendbird server

Note: UIKit automatically establishes a connection when necessary. If a connection with Sendbird server is required before using a UIKit component, explicitly use the SendBirdUIKit.connect() method to establish a connection.

Connect a user to Sendbird server using the SendBirdUIKit.connect() method. This method will connect a user to the server with the information you implemented on the SendBirdUIKItAdapter. The connect() method will automatically connect and update the user profile to the server. If successful, the latest user instance are returned through the callback.

Light Color Skin
Copy
SendBirdUIKit.connect(new SendBird.ConnectHandler() {
    @Override
    public void onConnected(User user, SendBirdException e) {
        if (e != null) {    // Error
            return;
        }
        // The latest user instance has been received.
    }
});

Disconnect from Sendbird server

Call the SendBirdUIKit.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.

Light Color Skin
Copy
SendBirdUIKit.disconnect(new SendBird.DisconnectHandler() {
    @Override
    public void onDisconnected() {
        // The current user is disconnected from Sendbird server.
    }
});

Update user profile

Update a user's nickname or profile image using the SendBirdUIKit.updateUserInfo() method.

Note: Call this method after a connection is established.

Light Color Skin
Copy
SendBirdUIKit.updateUserInfo(NICKNAME, PROFILE_URL, new SendBird.UserInfoUpdateHandler() {
    @Override
    public void onUpdated(SendBirdException e) {
        if (e != null) {    // error
            return;
        }
    }
});