Desk SDKs Android v1
Desk SDKs Android
Desk SDKs
Android
Version 1

Authentication

Copy link

Before using features of the Desk SDK for Android in a client app, the SendBirdDesk instance must be initialized first when launching a client app. As the Desk SDK handles messages within a ticket based on Sendbird Chat, customers from Sendbird Chat should go through the user authentication with the Desk SDK before starting a chat with an agent.


Initialize the Desk SDK

Copy link

Initialize the SendBirdDesk instance when launching a client app. Next, copy APP_ID of your Sendbird application from the Sendbird Dashboard. Then, call the SendbirdChat.init(InitParams) method using the copied APP_ID within Application.onCreate(). Make sure to use the same APP_ID from the Chat SDK at this point. Lastly, call the SendBirdDesk.init() method within Application.onCreate().

// Initialize the SendBirdDesk instance to use APIs in your app.
public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        final InitParams initParams = new InitParams(APP_ID, this, false);
        SendbirdChat.init(initParams, new InitResultHandler() {
            @Override
            public void onMigrationStarted() {
            }

            @Override
            public void onInitFailed(SendbirdException e) {
                // If initialization fails, this method is called.
            }

            @Override
            public void onInitSucceed() {
                // If initialization is successful, this method is called and you can proceed to the next step.
                // You can use all Sendbird APIs, including connect(), after init is completed in your app.
                SendBirdDesk.init();
            }
        });
    }
}

Note: If you call SendBirdDesk.init() again after calling SendbirdChat.init(InitParams) with a different APP_ID, all existing Desk-related data in the client app will be deleted.

Depending on the chat environment you want to provide to provide to your customers, you can use the Chat SDK alone or both the Chat and Desk SDKs together.

Usage of SDKs

Copy link
SDKUsed for

Chat SDK

In-app messenger where customers can chat with each other.

Chat and Desk SDKs

Tickets where customers can chat with agents.


Authenticate a customer from Sendbird Chat

Copy link

Every ticket in Sendbird Desk is mapped to a group channel in Sendbird Chat because messages within a ticket are handled by Sendbird Chat. Therefore, your customer needs authentications from both the Chat SDK and the Desk SDK to receive and send a message within a ticket. To authenticate a customer, use the SendbirdChat.connect() and the SendBirdDesk.authenticate() methods with a customer's user ID used in Sendbird Chat.

// Use a user ID that is unique to your Sendbird application.
SendbirdChat.connect(userId, accessToken, new ConnectHandler() {
    @Override
    public void onConnected(User user, SendbirdException e) {
        if (e != null) {    // error.
            return;
        }
        // Use the same userId and accessToken used in SendbirdChat.connect().
        SendBirdDesk.authenticate(userId, accessToken, new SendBirdDesk.AuthenticateHandler() {
            @Override
            public void onResult(SendbirdException e) {
                if (e != null) {    //error.
                    return;
                }

                // SendBirdDesk is now initialized, and the customer is authenticated.
            }
        });
    }
});

If you're implementing the Chat SDK and the Desk SDK simultaneously, connect a user to Sendbird server with their user ID and access token first.

Note: Customers from social media, such as Instagram or Twitter, are automatically authenticated on the Sendbird Dashboard with their social media account.