Rate this page:

Client

The Client class is used to control platform functions. Cannot be instantiated directly (singleton), so use the Voximplant.getInstance method to get the class instance.

Methods

call

Copy URL
call(number: 

string

,
callSettings:

CallSettings

):

Promise<Call>

Creates an outgoing call.Important: There is a difference between resolving the Client.call promise and handling CallEventTypes. If the promise is resolved, the SDK sends a call to the cloud. However, it does not mean that a call is connected; to catch this call state, subscribe to the CallEventTypes.Connected event. If the promise is rejected, that indicates the issues in the application's code (e.g., a try to make a call without login to the Voximplant cloud); in case of the CallFailed event is triggered, that means a telecom-related issue (e.g., another participant rejects a call).

Parameters

  • number:

    string

    The number to call. For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario.

  • callSettings:

    CallSettings

    Optional

    Optional call settings

Returns

callConference

Copy URL
callConference(number: 

string

,
callSettings:

CallSettings

):

Promise<Call>

Creates a call to a dedicated conference without proxy session. For details see the video conferencing guide.Important: There is a difference between resolving the Client.callConference promise and handling CallEventTypes. If the promise is resolved, the SDK sends a call to the cloud. However, it does not mean that a call is connected; to catch this call state, subscribe to the CallEventTypes.Connected event. If the promise is rejected, that indicates the issues in the application's code (e.g., a try to make a call without login to the Voximplant cloud); in case of the CallFailed event is triggered, that means a telecom-related issue (e.g., another participant rejects a call).

Parameters

  • number:

    string

    The number to call. For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario.

  • callSettings:

    CallSettings

    Optional

    Optional call settings

Returns

connect

Copy URL
connect(options: 

ConnectOptions

):

Promise<ClientEventTypes.ConnectionEstablished,ClientEventTypes.ConnectionFailed>

Connects to the Voximplant Cloud.

Parameters

disconnect

Copy URL
disconnect(): 

Promise<ClientEventTypes.ConnectionClosed>

Disconnects from the Voximplant Cloud.

getClientState

Copy URL
getClientState(): 

Promise<ClientState>

Gets the current client state.

Returns

handlePushNotification

Copy URL
handlePushNotification(notification: 

object

):

void

Handles an incoming push notification.

Parameters

  • notification:

    object

    Incoming push notification

Returns

  • type:

    void

login

Copy URL
login(username: 

string

,
password:

string

):

Promise<ClientEventTypes.AuthResult>

Logs in to the specified Voximplant application with password.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

  • password:

    string

    User password

Returns

loginWithOneTimeKey

Copy URL
loginWithOneTimeKey(username: 

string

,
hash:

string

):

Promise<ClientEventTypes.AuthResult>

Logs in to the specified Voximplant application via the 'onetimekey' authorization method. Hash should be calculated with the key received in AuthResult event. Please check this article for details.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

  • hash:

    string

    Hash that is generated by 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 "@". So if you pass myuser@myapp.myacc.voximplant.com as a username, you should only use myuser while computing this hash.

Returns

loginWithToken

Copy URL
loginWithToken(username: 

string

,
token:

string

):

Promise<ClientEventTypes.AuthResult>

Logs in to the specified Voximplant application via the accessToken.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

  • token:

    string

    Access token that has been obtained in the AuthResult event

Returns

off

Copy URL
off(eventType: 

ClientEventTypes

,
event:

Function

):

void

Removes the handler for the specified event.

Parameters

  • event:

    Function

    Optional

    Handler function. If not specified, all handlers for the event are removed.

Returns

  • type:

    void

on

Copy URL
on(eventType: 

ClientEventTypes

,
event:

Function

):

void

Registers a handler for the specified client event. Use the Client.off method to delete a handler.

Parameters

Returns

  • type:

    void

registerIMPushNotificationsTokenIOS

Copy URL
IOS
registerIMPushNotificationsTokenIOS(token: 

string

):

void

Registers Apple Push Notifications token for IM push notifications.See React Native PushNotificationIOS for more details.

IM push notification token for Android is the same as VoIP push notification token and should be registered once via Client.registerPushNotificationsToken.

Parameters

  • token:

    string

    The APNS token for IM push notifications.

Returns

  • type:

    void

registerPushNotificationsToken

Copy URL
registerPushNotificationsToken(token: 

string

):

void

Registers for VoIP push notifications. Only PushKit VoIP tokens are acceptable.Application can receive push notifications from the Voximplant server after the first login.

Parameters

  • token:

    string

    Push registration token

Returns

  • type:

    void

requestOneTimeLoginKey

Copy URL
requestOneTimeLoginKey(username: 

string

):

Promise<ClientEventTypes.AuthResult>

Requests a key for the 'onetimekey' authorization method. Server returns the key in the AuthResult event with 302 code.The AuthResult's 'result' field informs about the successful authorization. Since the authorization with one-time key consists of several steps, at the moment of authorization code request the user is not authorized yet. Thus, the 'result' field can have the 'false' value, but the request is successful if the response code is 302.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

Returns

setLoggerCallback

Copy URL
setLoggerCallback(callback: 

Function

):

void

Sets the outer logging callback. The method allows logging pipeline integration of the Voximplant React Native SDK into your own logger i.e. the method call sends all events to your function.

Parameters

  • callback:

    Function

    Callback function with two arguments: level and message

Returns

  • type:

    void

tokenRefresh

Copy URL
tokenRefresh(username: 

string

,
refreshToken:

string

):

Promise<ClientEventTypes.RefreshTokenResult>

Refreshes the expired access token.

Parameters

  • username:

    string

    Fully-qualified username that includes Voximplant user, application and account names. The format is: "username@appname.accname.voximplant.com".

  • refreshToken:

    string

    Refresh token that has been obtained in the AuthResult event

unregisterIMPushNotificationsTokenIOS

Copy URL
IOS
unregisterIMPushNotificationsTokenIOS(token: 

string

):

void

Unregisters from IM push notifications. Application no longer receives IM push notifications from the Voximplant server after calling this method.

Parameters

  • token:

    string

    The APNS token for IM push notifications.

Returns

  • type:

    void

unregisterPushNotificationsToken

Copy URL
unregisterPushNotificationsToken(token: 

string

):

void

Unregisters from push notifications. Application no longer receives push notifications from the Voximplant server after calling this method.

Parameters

  • token:

    string

    Push registration token

Returns

  • type:

    void