VIClient
Interface that may be used to connect, login to the Voximplant CLoud, make and receive audio and video calls.
Methods
call
Future<VICall>
call(String
number, settings)
Creates a new VICall instance and starts the outgoing call.
Throws VIException, if the client is not logged in, otherwise returns VICall instance.
Errors:
- ERROR_CLIENT_NOT_LOGGED_IN - If the client is not logged in
- ERROR_MISSING_PERMISSION - Android only. If permissions are not granted for the call: audio calls - RECORD_AUDIO video calls - RECORD_AUDIO and CAMERA
Parameters
number:
String
The call destination that might be Voximplant username, phone number or SIP URI. Actual routing is then performed by a VoxEngine scenario.
settings:
OptionalAdditional call parameters like video direction for the call, preferred video codec, custom data.
Returns
type:
Future<VICall>
conference
Future<VICall>
conference(String
conference, settings)
Creates a new VICall instance and starts the conference.
Throws VIException, if the client is not logged in, otherwise returns VICall instance.
Errors:
- ERROR_CLIENT_NOT_LOGGED_IN - If the client is not logged in
- ERROR_MISSING_PERMISSION - Android only. If permissions are not granted for the call: audio calls - RECORD_AUDIO video calls - RECORD_AUDIO and CAMERA
Parameters
conference:
String
The call destination. For SIP compatibility reasons it should be a non-empty string even if the number itself is not used by a Voximplant cloud scenario.
settings:
OptionalAdditional call parameters like video direction for the call, preferred video codec, custom data.
Returns
type:
Future<VICall>
connect
Future<void>
connect({ node, bool
connectivityCheck = false, List<String>?
servers})
Connects to the Voximplant Cloud.
Checks whether UDP traffic will flow correctly between device and the Voximplant Cloud if [connectivityCheck] is enabled (disabled by default).
Throws VIException if the connection to the Voximplant Cloud could not be established.
Errors:
- ERROR_CONNECTION_FAILED - If the connection is currently establishing or already established, or an error occurred.
Parameters
node:
Specifies the node the Voximplant account belongs to.
connectivityCheck:
bool
OptionalChecks whether UDP traffic will flow correctly between device and Voximplant cloud. This check reduces connection speed.
servers:
List<String>?
OptionalList of server names of particular media gateways for connection.
Returns
type:
Future<void>
disconnect
Future<void>
disconnect()
Closes the connection with the Voximplant Cloud.
Returns
type:
Future<void>
getClientState
Future<VIClientState>
getClientState()
Returns the current client state
Returns
type:
Future<VIClientState>
handlePushNotification
Future<void>
handlePushNotification(Map<String, dynamic>
message)
Handles incoming push notification.
Throws VIException, if [message] is null.
Errors:
- ERROR_INVALID_ARGUMENTS - If [message] is null.
Parameters
message:
Map<String, dynamic>
Incoming push notification payload
Returns
type:
Future<void>
login
Future<VIAuthResult>
login(String
username, String
password)
Logs in a user with the given Voximplant username and password.
Throws VIException, if login process failed, otherwise returns VIAuthResult.
Errors:
- ERROR_ACCOUNT_FROZEN - If the account is frozen.
- ERROR_MAU_ACCESS_DENIED - Monthly Active Users (MAU) limit is reached. Payment is required.
- ERROR_INTERNAL - If an internal error occurred.
- ERROR_INVALID_PASSWORD - if the given password is invalid.
- ERROR_INVALID_STATE - If the client is not connected, already logged in, or currently logging in.
- ERROR_INVALID_USERNAME - If the given username is invalid.
- ERROR_NETWORK_ISSUES - If the connection to the Voximplant Cloud is closed while the client is logging in.
- ERROR_TIMEOUT - If timeout occurred.
Parameters
username:
String
Full user name, including Voximplant user, application, and account name in the format
user@application.account.voximplant.com
.password:
String
User password.
Returns
type:
Future<VIAuthResult>
loginWithAccessToken
Future<VIAuthResult>
loginWithAccessToken(String
username, String
token)
Logs in a user with the given Voximplant username and access token.
Throws VIException, if login process failed, otherwise returns VIAuthResult.
Errors:
- ERROR_ACCOUNT_FROZEN - If the account is frozen.
- ERROR_INTERNAL - If an internal error occurred.
- ERROR_INVALID_STATE - If the client is not connected, already logged in, or currently logging in.
- ERROR_INVALID_USERNAME - If the given username is invalid.
- ERROR_NETWORK_ISSUES - If the connection to the Voximplant Cloud is closed while the client is logging in.
- ERROR_TIMEOUT - If timeout occurred.
- ERROR_TOKEN_EXPIRED - If the access token is expired.
Parameters
username:
String
Full user name, including Voximplant user, application, and account name in the format
user@application.account.voximplant.com
.token:
String
Access token that was obtained from VIAuthResult.loginTokens after previous successful login.
Returns
type:
Future<VIAuthResult>
loginWithOneTimeKey
Future<VIAuthResult>
loginWithOneTimeKey(String
username, String
hash)
Logs in a user with the given Voximplant username and one time key that was generated before.
Throws VIException, if login process failed, otherwise returns VIAuthResult.
Errors:
- ERROR_ACCOUNT_FROZEN - If the account is frozen.
- ERROR_MAU_ACCESS_DENIED - Monthly Active Users (MAU) limit is reached. Payment is required.
- ERROR_INTERNAL - If an internal error occurred.
- ERROR_INVALID_PASSWORD - if the given password is invalid.
- ERROR_INVALID_STATE - If the client is not connected, already logged in, or currently logging in.
- ERROR_INVALID_USERNAME - If the given username is invalid.
- ERROR_NETWORK_ISSUES - If the connection to the Voximplant Cloud is closed while the client is logging in.
- ERROR_TIMEOUT - If timeout occurred.
Parameters
username:
String
Full user name, including Voximplant user, application, and account name in the format
user@application.account.voximplant.com
.hash:
String
Hash that was generated using following formula: MD5(oneTimeKey+"|"+MD5(user+":voximplant.com:"+password)).
Returns
type:
Future<VIAuthResult>
registerForPushNotifications
Future<void>
registerForPushNotifications(String
pushToken)
Registers for VoIP push notification with the given token.
Application will receive push notifications from Voximplant Server after first login.
Throws VIException, if [pushToken] is null.
Errors:
- ERROR_INVALID_ARGUMENTS - If [pushToken] is null.
Parameters
pushToken:
String
Push notification token.
Returns
type:
Future<void>
registerIMPushNotificationsTokenIOS
Future<void>
registerIMPushNotificationsTokenIOS(String
imToken)
Register Apple Push Notifications token.
After calling this function application will receive push notifications from Voximplant Server. If the provided token is not nil, but the client is not logged in, the token will be registered just after login.
IOS ONLY.
Parameters
imToken:
String
The APNS token for IM push notification.
Returns
type:
Future<void>
requestOneTimeLoginKey
Future<String>
requestOneTimeLoginKey(String
username)
Generates one time login key for the given Voximplant username.
Throws VIException, if an error occurred, otherwise returns one time key.
Errors:
- ERROR_ACCOUNT_FROZEN - If the account is frozen.
- ERROR_INTERNAL - If an internal error occurred.
- ERROR_INVALID_STATE - If the client is not connected, already logged in, or currently logging in.
- ERROR_INVALID_USERNAME - If the given username is invalid.
- ERROR_NETWORK_ISSUES - If the connection to the Voximplant Cloud is closed while the client is logging in.
- ERROR_TIMEOUT - If timeout occurred.
Parameters
username:
String
Full user name, including Voximplant user, application, and account name in the format
user@application.account.voximplant.com
.
Returns
type:
Future<String>
tokenRefresh
Future<VILoginTokens>
tokenRefresh(String
username, String
token)
Performs refresh of access token for the given Voximplant username using refresh token.
Throws VIException, if refresh process failed, otherwise returns new tokens.
Errors:
- ERROR_ACCOUNT_FROZEN - If the account is frozen.
- ERROR_INTERNAL - If an internal error occurred.
- ERROR_INVALID_STATE - If the client is not connected, already logged in, or currently logging in.
- ERROR_INVALID_USERNAME - If the given username is invalid.
- ERROR_NETWORK_ISSUES - If the connection to the Voximplant Cloud is closed while the client is logging in.
- ERROR_TIMEOUT - If timeout occurred.
- ERROR_TOKEN_EXPIRED - If the refresh token is expired.
Parameters
username:
String
Full user name, including Voximplant user, application, and account name in the format
user@application.account.voximplant.com
.token:
String
Refresh token can be obtained from VIAuthResult.loginTokens after previous successful login.
Returns
type:
Future<VILoginTokens>
unregisterFromPushNotifications
Future<void>
unregisterFromPushNotifications(String
pushToken)
Unregisters from VoIP push notifications.
Application will no longer receive push notifications from Voximplant Server.
Throws VIException, if [pushToken] is null.
Errors:
- ERROR_INVALID_ARGUMENTS - If [pushToken] is null.
Parameters
pushToken:
String
Push notification token.
Returns
type:
Future<void>
unregisterIMPushNotificationsTokenIOS
Future<void>
unregisterIMPushNotificationsTokenIOS(String
imToken)
Unregister Apple Push Notifications token.
After calling this function application stops receive push notifications from Voximplant Server. If the provided token is not nil, but the client is not logged in, the token will be unregistered just after login.
IOS ONLY.
Parameters
imToken:
String
The APNS token for IM push notification.
Returns
type:
Future<void>
Props
clientStateStream
Stream<VIClientState>
clientStateStream
Receive VIClientState each time the state is changed.
Returns
type:
Stream<VIClientState>
onIncomingCall
onIncomingCall
Callback for getting notified about new incoming call.
Returns
type:
onPushDidExpire
onPushDidExpire
Callback for getting notified when push notification is expired.
Returns
type: