> For a complete documentation index, fetch https://docs.voximplant.ai/llms.txt

# Client (object)

[com.voximplant.android.sdk.core](/api-reference/androidsdk3/android/sdk/core/overview)

Interface that connects, logs in, and manages push notifications tokens.

**Methods**

* [connect](/api-reference/androidsdk3/android/sdk/core/client#connect)
* [disconnect](/api-reference/androidsdk3/android/sdk/core/client#disconnect)
* [handlePushNotification](/api-reference/androidsdk3/android/sdk/core/client#handlepushnotification)
* [login](/api-reference/androidsdk3/android/sdk/core/client#login)
* [loginWithAccessToken](/api-reference/androidsdk3/android/sdk/core/client#loginwithaccesstoken)
* [loginWithOneTimeKey](/api-reference/androidsdk3/android/sdk/core/client#loginwithonetimekey)
* [refreshToken](/api-reference/androidsdk3/android/sdk/core/client#refreshtoken)
* [registerForPushNotifications](/api-reference/androidsdk3/android/sdk/core/client#registerforpushnotifications)
* [requestOneTimeKey](/api-reference/androidsdk3/android/sdk/core/client#requestonetimekey)
* [setClientSessionListener](/api-reference/androidsdk3/android/sdk/core/client#setclientsessionlistener)
* [unregisterFromPushNotifications](/api-reference/androidsdk3/android/sdk/core/client#unregisterfrompushnotifications)

**Properties**

* [clientState](/api-reference/androidsdk3/android/sdk/core/client#clientstate)
* [displayName](/api-reference/androidsdk3/android/sdk/core/client#displayname)

## Methods

### connect

`fun connect(options: `[`ConnectOptions`](/api-reference/androidsdk3/android/sdk/core/connectoptions)`, callback: `[`ConnectionCallback`](/api-reference/androidsdk3/android/sdk/core/connectioncallback)`): Unit`

Connects to the Voximplant cloud.

**Parameters**

| Parameter  | Type                                                                                   | Requirement | Description                                    |
| ---------- | -------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------- |
| `options`  | [`ConnectOptions`](/api-reference/androidsdk3/android/sdk/core/connectoptions)         |             | Connect options                                |
| `callback` | [`ConnectionCallback`](/api-reference/androidsdk3/android/sdk/core/connectioncallback) |             | Object to receive the result of this operation |

**Returns:** Unit

### disconnect

`fun disconnect(): Unit`

Closes the connection with the Voximplant Cloud.

If this method is called while client is disconnected, [ClientSessionListener.onConnectionClosed](/api-reference/androidsdk3/android/sdk/core/clientsessionlistener#onconnectionclosed) is triggered with [DisconnectReason.AlreadyDisconnected](/api-reference/androidsdk3/android/sdk/core/disconnectreason#alreadydisconnected) reason.

**Returns:** Unit

### handlePushNotification

`fun handlePushNotification(notification: Map<String, String>): Unit`

Handles an incoming push notification.

**Parameters**

| Parameter      | Type                  | Requirement | Description                                                                                                        |
| -------------- | --------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------ |
| `notification` | `Map<String, String>` |             | Incoming push notification that comes from FirebaseMessagingService.onMessageReceived(RemoteMessage remoteMessage) |

**Returns:** Unit

### login

`fun login(username: String, password: String, callback: `[`LoginCallback`](/api-reference/androidsdk3/android/sdk/core/logincallback)`): Unit`

Logs in to the specified Voximplant application with password.

**Parameters**

| Parameter  | Type                                                                         | Requirement | Description                                                                                        |
| ---------- | ---------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------- |
| `username` | `String`                                                                     |             | Full user name, including app and account name, like `someuser@someapp.youraccount.voximplant.com` |
| `password` | `String`                                                                     |             | User password                                                                                      |
| `callback` | [`LoginCallback`](/api-reference/androidsdk3/android/sdk/core/logincallback) |             |                                                                                                    |

**Returns:** Unit

### loginWithAccessToken

`fun loginWithAccessToken(username: String, accessToken: String, callback: `[`LoginCallback`](/api-reference/androidsdk3/android/sdk/core/logincallback)`): Unit`

Performs login via the specified username and access token that has been obtained in [LoginCallback.onSuccess](/api-reference/androidsdk3/android/sdk/core/logincallback#onsuccess) callback before.

**Parameters**

| Parameter     | Type                                                                         | Requirement | Description                                                                                        |
| ------------- | ---------------------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------- |
| `username`    | `String`                                                                     |             | Full user name, including app and account name, like `someuser@someapp.youraccount.voximplant.com` |
| `accessToken` | `String`                                                                     |             | Access token that is obtained in onLoginSuccessful callback                                        |
| `callback`    | [`LoginCallback`](/api-reference/androidsdk3/android/sdk/core/logincallback) |             |                                                                                                    |

**Returns:** Unit

### loginWithOneTimeKey

`fun loginWithOneTimeKey(username: String, hash: String, callback: `[`LoginCallback`](/api-reference/androidsdk3/android/sdk/core/logincallback)`): Unit`

Performs login via one time key that has been generated before.

Check [this article](https://voximplant.com/docs/guides/sdk/authorization-onetimekey) for details.

**Parameters**

`username`

**Type:** String

Full user name, including app and account name, like `someuser@someapp.youraccount.voximplant.com`

`hash`

**Type:** String

Hash that is generated via the following formula: `MD5(oneTimeKey+"|"+MD5(user+":voximplant.com:"+password))`

Please note that here user is just a user name, without app name, account name or anything else after "@".

`callback`

**Type:** [LoginCallback](/api-reference/androidsdk3/android/sdk/core/logincallback)

**Returns:** Unit

### refreshToken

`fun refreshToken(username: String, refreshToken: String, callback: `[`RefreshTokenCallback`](/api-reference/androidsdk3/android/sdk/core/refreshtokencallback)`): Unit`

Performs refresh of login tokens required for login via access token.

**Parameters**

| Parameter      | Type                                                                                       | Requirement | Description                                                                                        |
| -------------- | ------------------------------------------------------------------------------------------ | ----------- | -------------------------------------------------------------------------------------------------- |
| `username`     | `String`                                                                                   |             | Full user name, including app and account name, like `someuser@someapp.youraccount.voximplant.com` |
| `refreshToken` | `String`                                                                                   |             | Refresh token that is obtained in onLoginSuccessful callback                                       |
| `callback`     | [`RefreshTokenCallback`](/api-reference/androidsdk3/android/sdk/core/refreshtokencallback) |             |                                                                                                    |

**Returns:** Unit

### registerForPushNotifications

`fun registerForPushNotifications(pushConfig: `[`PushConfig`](/api-reference/androidsdk3/android/sdk/core/pushconfig)`, callback: `[`RegisterPushTokenCallback`](/api-reference/androidsdk3/android/sdk/core/registerpushtokencallback)`?): Unit`

Registers for push notifications. Application can receive push notifications from Voximplant Server after first log in.

The API may be called in any client state, but the push token is registered only after login successful.

**Parameters**

| Parameter    | Type                                                                                                    | Requirement | Description                                    |
| ------------ | ------------------------------------------------------------------------------------------------------- | ----------- | ---------------------------------------------- |
| `pushConfig` | [`PushConfig`](/api-reference/androidsdk3/android/sdk/core/pushconfig)                                  |             | Push token configuration                       |
| `callback`   | [`RegisterPushTokenCallback`](/api-reference/androidsdk3/android/sdk/core/registerpushtokencallback)`?` |             | Object to receive the result of this operation |

**Returns:** Unit

### requestOneTimeKey

`fun requestOneTimeKey(username: String, callback: `[`GenerateOneTimeKeyCallback`](/api-reference/androidsdk3/android/sdk/core/generateonetimekeycallback)`): Unit`

Generates one time login key for automated login process.

Check [this article](https://voximplant.com/docs/guides/sdk/authorization-onetimekey) for details.

**Parameters**

| Parameter  | Type                                                                                                   | Requirement | Description                                                                                        |
| ---------- | ------------------------------------------------------------------------------------------------------ | ----------- | -------------------------------------------------------------------------------------------------- |
| `username` | `String`                                                                                               |             | Full user name, including app and account name, like `someuser@someapp.youraccount.voximplant.com` |
| `callback` | [`GenerateOneTimeKeyCallback`](/api-reference/androidsdk3/android/sdk/core/generateonetimekeycallback) |             |                                                                                                    |

**Returns:** Unit

### setClientSessionListener

`fun setClientSessionListener(listener: `[`ClientSessionListener`](/api-reference/androidsdk3/android/sdk/core/clientsessionlistener)`?): Unit`

Sets the ClientSessionListener listener to handle events related to the connection with the Voximplant Cloud.

**Parameters**

| Parameter  | Type                                                                                            | Requirement | Description                                                                                                                                                   |
| ---------- | ----------------------------------------------------------------------------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `listener` | [`ClientSessionListener`](/api-reference/androidsdk3/android/sdk/core/clientsessionlistener)`?` |             | [ClientSessionListener](/api-reference/androidsdk3/android/sdk/core/clientsessionlistener) listener or null. If null, any previously set listener is removed. |

**Returns:** Unit

### unregisterFromPushNotifications

`fun unregisterFromPushNotifications(pushConfig: `[`PushConfig`](/api-reference/androidsdk3/android/sdk/core/pushconfig)`, callback: `[`RegisterPushTokenCallback`](/api-reference/androidsdk3/android/sdk/core/registerpushtokencallback)`?): Unit`

Unregisters from push notifications. Application can no longer receive push notifications from the Voximplant server.

The API may be called in any Client state, but the push token is unregistered only after a successful login.

**Parameters**

| Parameter    | Type                                                                                                    | Requirement | Description                                                             |
| ------------ | ------------------------------------------------------------------------------------------------------- | ----------- | ----------------------------------------------------------------------- |
| `pushConfig` | [`PushConfig`](/api-reference/androidsdk3/android/sdk/core/pushconfig)                                  |             | Configuration for push notifications including push token and bundle id |
| `callback`   | [`RegisterPushTokenCallback`](/api-reference/androidsdk3/android/sdk/core/registerpushtokencallback)`?` |             | Object to receive the result of this operation                          |

**Returns:** Unit

## Properties

### clientState

`val clientState: `[`ClientState`](/api-reference/androidsdk3/android/sdk/core/clientstate)

Gets the current client state.

**Read-only.**

### displayName

`val displayName: String?`

Gets the current user's display name. Display name is available only when the user is logged in, otherwise the property returns null.

**Read-only.**