SIGN UP

Client

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

Methods

call

call(number: string, callSettings: CallSettings): Promise<Call>

Create outgoing call.

Important: There is a difference between resolving the Client.call promise and handling CallEvents. If the promise is resolved, the SDK sends a call to the cloud. However, it doesn't mean that a call is connected; to catch this call state, subscribe to the CallEvents.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

  • Return:

    Promise<Call>

callConference

callConference(number: string, callSettings: CallSettings): Promise<Call>

Create 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 CallEvents. If the promise is resolved, the SDK sends a call to the cloud. However, it doesn't mean that a call is connected; to catch this call state, subscribe to the CallEvents.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

  • Return:

    Promise<Call>

connect

connect(options: ConnectOptions): Promise<ConnectionEstablished|ConnectionFailed>

Connect to the Voximplant Cloud

Parameters

Returns

disconnect

disconnect(): Promise<ConnectionClosed>

Disconnect from the Voximplant Cloud

Returns

getClientState

getClientState(): Promise<ClientState>

Get current client state

Returns

handlePushNotification

handlePushNotification(notification: object): void

Handle incoming push notification

Parameters

  • notification:

    object

    Incoming push notification

login

login(username: string, password: string): Promise<AuthResult>

Login to 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

loginWithOneTimeKey(username: string, hash: string): Promise<AuthResult>

Login to specified Voximplant application using 'onetimekey' auth method. Hash should be calculated with the key received in AuthResult event. Please, read howto page

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 was generated using 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

loginWithToken(username: string, token: string): Promise<AuthResult>

Login to specified Voximplant application using 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 was obtained in AuthResult event

Returns

off

off(event: ClientEvents, handler: function): void

Remove handler for specified event

Parameters

on

on(event: ClientEvents, handler: function): void

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

Parameters

registerIMPushNotificationsTokenIOS

registerIMPushNotificationsTokenIOS(token: string): void

Register 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 IOS ONLY.

Parameters

  • token:

    string

    The APNS token for IM push notifications.

registerPushNotificationsToken

registerPushNotificationsToken(token: string): void

Register for VoIP push notifications. Only PushKit VoIP tokens are acceptable.

Application will receive push notifications from the Voximplant Server after the first login.

Parameters

  • token:

    string

    Push registration token

requestOneTimeLoginKey

requestOneTimeLoginKey(username: string): Promise<AuthResult>

Request a key for 'onetimekey' auth method. Server will send the key in AuthResult event with code 302

Parameters

  • username:

    string

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

Returns

tokenRefresh

tokenRefresh(username: string, refreshToken: string): Promise<AuthTokenResult>

Refresh 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 was obtained in AuthResult event

Returns

unregisterPushNotificationsToken

unregisterPushNotificationsToken(token: string): void

Unregister from push notifications. Application will no longer receive push notifications from the Voximplant server

Parameters

  • token:

    string

    Push registration token