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

# VIClient

Interface that provides API to connect and log in to the Voximplant Cloud.

@objc final class VIClient

## Properties

### delegate

@objc weak var delegate: [VIClientSessionDelegate](/api-reference/iossdk/core/viclientsessiondelegate)? \{ get set }

Session delegate that handles events for the connection to the Voximplant Cloud.

### shared

@objc static let shared: [VIClient](/api-reference/iossdk/core/viclient)

Shared client instance.

### state

@objc var state: [VIClientState](/api-reference/iossdk/core/viclientstate) \{ get }

Current client state.

## Methods

### connect(to:gateways:completion:)

@objc func connect(\
    to node: [VINode](/api-reference/iossdk/core/vinode),\
    gateways: \[String]? = \[],\
    completion: @escaping ([VIConnectionError](/api-reference/iossdk/core/viconnectionerror)?) -> Void\
)

Connects to the Voximplant Cloud.

**Parameters**

**node** [VINode](/api-reference/iossdk/core/vinode)

Node the Voximplant account belongs to. Find more information about [VINode](/api-reference/iossdk/core/vinode) in the [getting started guide](/getting-started/platform/ios).

**gateways** \[String]?

Optional. Array of the media gateway servers for connection. The default value is an empty array.

**completion** @escaping ([VIConnectionError](/api-reference/iossdk/core/viconnectionerror)?) -> Void

Completion handler to call when the connection is complete. This handler is executed on the delegate queue. The SDK passes a [VIConnectionError](/api-reference/iossdk/core/viconnectionerror) object if the operation has failed

### disconnect()

@objc func disconnect()

Disconnects from the Voximplant Cloud.

### handlePushNotification(pushPayload:)

@objc func handlePushNotification(pushPayload: \[AnyHashable : Any]) -> UUID?

Handles an incoming push notification.

**Parameters**

**pushPayload** \[AnyHashable : Any]

Incoming notification which comes from [pushRegistry(\_:didReceiveIncomingPushWith:for:completion:)](https://developer.apple.com/documentation/pushkit/pkpushregistrydelegate/pushregistry\(_:didreceiveincomingpushwith:for:completion:\))

**Return Value**

UUID that can be used as the [CXCall.uuid](https://developer.apple.com/documentation/callkit/cxcall/uuid) for CallKit integration.

Can be called in any [VIClientState](/api-reference/iossdk/core/viclientstate), but to receive an incoming call instance, it is required to connect to the Voximplant Cloud and log in. After the login, the [VICallManagerDelegate.callManager(\_:didReceiveIncomingCall:withVideo:headers:)](/api-reference/iossdk/calls/vicallmanagerdelegate#symbol-b1827d8d55ef6538) method is called to provide access to the [VICall](/api-reference/iossdk/calls/vicall) object.

### login(withOneTimeKey:user:completion:)

@objc func login(\
    withOneTimeKey key: String,\
    user: String,\
    completion: @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void\
)

Logs in a user with a one-time key to the Voximplant Cloud.

**Parameters**

**key** String

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

**user** String

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

**completion** @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VILoginResult](/api-reference/iossdk/core/viloginresult) object with the user display name and tokens if the operation has completed successfully, or a [VILoginError](/api-reference/iossdk/core/viloginerror) object if the operation has failed

### login(withPassword:user:completion:)

@objc func login(\
    withPassword password: String,\
    user: String,\
    completion: @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void\
)

Logs in a user with a password to the Voximplant Cloud.

**Parameters**

**password** String

User password

**user** String

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

**completion** @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VILoginResult](/api-reference/iossdk/core/viloginresult) object with the user display name and tokens if the operation has completed successfully, or a [VILoginError](/api-reference/iossdk/core/viloginerror) object if the operation has failed

### login(withToken:user:completion:)

@objc func login(\
    withToken token: String,\
    user: String,\
    completion: @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void\
)

Logs in a user with an access token to the Voximplant Cloud.

**Parameters**

**token** String

Access token. It is obtained either from [auth](/api-reference/iossdk/core/viloginresult#symbol-726217425bdaa226), or via [refreshTokens(forUser:refreshToken:completion:)](/api-reference/iossdk/core/viclient#symbol-bef0d17786ea85ed)

**user** String

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

**completion** @escaping ([VILoginResult](/api-reference/iossdk/core/viloginresult)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VILoginResult](/api-reference/iossdk/core/viloginresult) object with the user display name and tokens if the operation has completed successfully, or a [VILoginError](/api-reference/iossdk/core/viloginerror) object if the operation has failed

### refreshTokens(forUser:refreshToken:completion:)

@objc func refreshTokens(\
    forUser user: String,\
    refreshToken: String,\
    completion: @escaping ([VIAuth](/api-reference/iossdk/core/viauth)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void\
)

Performs a refresh of login tokens required for [login(withToken:user:completion:)](/api-reference/iossdk/core/viclient#symbol-0a8cefdc66f8472d).

**Parameters**

**user** String

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

**refreshToken** String

Refresh token obtained via [auth](/api-reference/iossdk/core/viloginresult#symbol-726217425bdaa226)

**completion** @escaping ([VIAuth](/api-reference/iossdk/core/viauth)?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VIAuth](/api-reference/iossdk/core/viauth) object with tokens if the operation has completed successfully or a [VILoginError](/api-reference/iossdk/core/viloginerror) object if the operation has failed

### registerIMPushNotificationsToken(\_:bundleId:completion:)

@objc func registerIMPushNotificationsToken(\
    \_ imToken: Data,\
    bundleId: String? = nil,\
    completion: @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void\
)

Registers an Apple Push Notifications token.

**Parameters**

**imToken** Data

APNs token for IM push notifications

**bundleId** String?

Application bundle id. Set only if push notifications are going to be sent across several iOS apps via a single Voximplant application or if you add several push certificates. The default value is nil.

**completion** @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror) object if the operation has failed, otherwise the value is nil.

After calling this method, the application can receive push notifications from the Voximplant Cloud. If the client is not logged in, the token is to be registered just after login.

### registerVoIPPushNotificationsToken(\_:bundleId:completion:)

@objc func registerVoIPPushNotificationsToken(\
    \_ voipToken: Data,\
    bundleId: String? = nil,\
    completion: @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void\
)

Registers an Apple VoIP Push Notifications token.

**Parameters**

**voipToken** Data

APNs token for VoIP push notifications which comes from [pushRegistry(\_:didUpdate:for:)](https://developer.apple.com/documentation/pushkit/pkpushregistrydelegate/pushregistry\(_:didupdate:for:\))

**bundleId** String?

Application bundle id. Set only if push notifications are going to be sent across several iOS apps via a single Voximplant application or if you add several push certificates. The default value is nil.

**completion** @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror) object if the operation has failed, otherwise the value is nil.

After calling this method, the application can receive push notifications from the Voximplant Cloud. If the client is not logged in, the token is to be registered just after login.

### requestOneTimeKey(forUser:completion:)

@objc func requestOneTimeKey(\
    forUser user: String,\
    completion: @escaping (String?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void\
)

Generates a one-time login key to use in automated login process.

**Parameters**

**user** String

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

**completion** @escaping (String?, [VILoginError](/api-reference/iossdk/core/viloginerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes the one-time key if the operation is completed successfully or a [VILoginError](/api-reference/iossdk/core/viloginerror) object if the operation has failed

> **Note**
>
> For additional information please see the [guide](/platform/sdks/authorization/authorization-onetimekey)

### unregisterIMPushNotificationsToken(\_:bundleId:completion:)

@objc func unregisterIMPushNotificationsToken(\
    \_ imToken: Data,\
    bundleId: String? = nil,\
    completion: @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void\
)

Unregisters an Apple Push Notifications token.

**Parameters**

**imToken** Data

APNs token for IM push notification

**bundleId** String?

Application bundle id. Set only if push notifications are going to be sent across several iOS apps via a single Voximplant application or if you add several push certificates. The default value is nil.

**completion** @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror) object if the operation has failed, otherwise the value is nil.

After calling this method, the application cannot receive push notifications from the Voximplant Cloud. If the client is not logged in, the tokens are to be unregistered just after the login

### unregisterVoIPPushNotificationsToken(\_:bundleId:completion:)

@objc func unregisterVoIPPushNotificationsToken(\
    \_ voipToken: Data,\
    bundleId: String? = nil,\
    completion: @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void\
)

Unregisters Apple VoIP Push Notifications token.

**Parameters**

**voipToken** Data

APNs token for VoIP push notifications which comes from [pushRegistry(\_:didUpdate:for:)](https://developer.apple.com/documentation/pushkit/pkpushregistrydelegate/pushregistry\(_:didupdate:for:\))

**bundleId** String?

Application bundle id. Set only if push notifications are going to be sent across several iOS apps via a single Voximplant application or if you add several push certificates. The default value is nil.

**completion** @escaping ([VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror)?) -> Void

Completion handler to call when the operation is complete. This handler is executed on the delegate queue. The SDK passes a [VIPushTokenError](/api-reference/iossdk/core/vipushtokenerror) object if the operation has failed, otherwise the value is nil.

After calling this method, the application cannot receive push notifications from the Voximplant Cloud. If the client is not logged in, the token is to be unregistered just after the login.

## Relationships

**Inherits From:** NSObject

**Conforms To:** ObjectiveC.NSObjectProtocol, Swift.CVarArg, Swift.CustomDebugStringConvertible, Swift.CustomStringConvertible, Swift.Equatable, Swift.Hashable