VIMessenger
Interface that may be used to control messaging functions.
Methods
createConversation
Future<VIConversationEvent>
createConversation( config)
Creates a new conversation with the extended configuration.
Other parties of the conversation (online participants and logged in clients) can be informed about the conversation creation via the VIMessenger.onCreateConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
config:
Returns
type:
Future<VIConversationEvent>
editUser
Future<VIUserEvent>
editUser(Map<String, Object>?
customData, Map<String, Object>?
privateCustomData)
Edits the current user information.
Throws VIException, if operation failed, otherwise returns VIUserEvent instance. For all possible errors see VIMessagingError
Parameters
customData:
Map<String, Object>?
New custom data. If null, previously set custom data is not changed. If empty map, previously set custom data is removed.
privateCustomData:
Map<String, Object>?
New private custom data. If null, previously set private custom data is not changed. If empty map, previously set private custom data is removed.
Returns
type:
Future<VIUserEvent>
getConversation
Future<VIConversationEvent>
getConversation(String
uuid)
Gets a conversation by its UUID.
It is possible if:
- the user that calls the method is/has been a participant of this conversation
- the conversation is an available public conversation (see VIMessenger.getPublicConversations)
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
uuid:
String
Conversation UUID
Returns
type:
Future<VIConversationEvent>
getConversations
Future<List<VIConversationEvent>>
getConversations(List<String>
uuids)
Gets multiple conversations by the list of UUIDs. Maximum 30 conversations.
It is possible if:
- the user that calls the method is/was a participant of these conversations
- the conversations are the available public conversations (see VIMessenger.getPublicConversations)
Throws VIException, if operation failed, otherwise returns List of VIConversationEvent instances. For all possible errors see VIMessagingError
Parameters
uuids:
List<String>
List of conversation UUIDs. Maximum 30 conversations.
Returns
type:
Future<List<VIConversationEvent>>
getPublicConversations
Future<VIConversationListEvent>
getPublicConversations()
Gets all public conversations (VIConversation.publicJoin is true).
It is possible to get all public conversations (UUIDs) that are created by:
- the current user
- other users of the same child account
- users of the main Voximplant developer account
Throws VIException, if operation failed, otherwise returns VIConversationListEvent instance. For all possible errors see VIMessagingError
Returns
type:
Future<VIConversationListEvent>
getSubscriptions
Future<VISubscriptionEvent>
getSubscriptions()
Gets all current subscriptions, i.e., the list of users the current user is subscribed to.
Throws VIException, if operation failed, otherwise returns VISubscriptionEvent instance. For all possible errors see VIMessagingError
Returns
type:
Future<VISubscriptionEvent>
getUserByIMId
Future<VIUserEvent>
getUserByIMId(int
userId)
Gets the information for a user specified by the IM user id.
It is possible to get any user of the main Voximplant developer account or its child accounts.
Throws VIException, if operation failed, otherwise returns VIUserEvent instance. For all possible errors see VIMessagingError
Parameters
userId:
int
IM User id
Returns
type:
Future<VIUserEvent>
getUserByName
Future<VIUserEvent>
getUserByName(String
username)
Gets the information for a user specified by the Voximplant user name, e.g., 'username@appname.accname'.
It is possible to get any user of the main Voximplant developer account or its child accounts.
Throws VIException, if operation failed, otherwise returns VIUserEvent instance. For all possible errors see VIMessagingError
Parameters
username:
String
Voximplant user identifier
Returns
type:
Future<VIUserEvent>
getUsersByIMId
Future<List<VIUserEvent>>
getUsersByIMId(List<int>
users)
Gets the information for users specified by the list of the IM user ids. Maximum 50 users.
It is possible to get any users of the main Voximplant developer account or its child accounts.
Throws VIException, if operation failed, otherwise returns List of VIUserEvent instances. For all possible errors see VIMessagingError
Parameters
users:
List<int>
List of IM user ids
Returns
type:
Future<List<VIUserEvent>>
getUsersByName
Future<List<VIUserEvent>>
getUsersByName(List<String>
users)
Gets the information for users specified by the list of the Voximplant user names. Maximum 50 users.
It is possible to get any users of the main Voximplant developer account or its child accounts.
Throws VIException, if operation failed, otherwise returns List of VIUserEvent instances. For all possible errors see VIMessagingError
Parameters
users:
List<String>
List of Voximplant user identifiers, e.g., 'username@appname.accname'
Returns
type:
Future<List<VIUserEvent>>
joinConversation
Future<VIConversationEvent>
joinConversation(String
uuid)
Joins the current user to any conversation specified by the UUID.
It is possible only on the following conditions:
- a conversation is created by a user of the main Voximplant developer account or its child accounts
- public join is enabled (VIConversation.publicJoin is true)
- the conversation is not a direct one (VIConversation.direct is false)
Other parties of the conversation (online participants and logged in clients) can be informed about joining to the conversation via the VIMessenger.onEditConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
uuid:
String
Conversation UUID
Returns
type:
Future<VIConversationEvent>
leaveConversation
Future<VIConversationEvent>
leaveConversation(String
uuid)
Makes the current user to leave a conversation specified by the UUID.
It is possible only if the conversation is not a direct one (VIConversation.direct is false) After a successful method call the conversation's UUID is added to VIUser.leaveConversationList.
Other parties of the conversation (online participants and logged in clients) can be informed about leaving the conversation via the VIMessenger.onEditConversation callback.
Throws VIException, if operation failed, otherwise returns VIConversationEvent instance. For all possible errors see VIMessagingError
Parameters
uuid:
String
Conversation UUID
Returns
type:
Future<VIConversationEvent>
managePushNotifications
Future<VIUserEvent>
managePushNotifications(List<VIMessengerNotification>?
notifications)
Manages messenger push notification subscriptions for the current user.
Throws VIException, if operation failed, otherwise returns VIUserEvent instance. For all possible errors see VIMessagingError
Parameters
notifications:
List<VIMessengerNotification>?
List of VIMessengerNotification
Returns
type:
Future<VIUserEvent>
recreateConversation
recreateConversation(String
uuid, conversationConfig, int
lastSequence, int
lastUpdateTime, int
createdTime)
Recreates a conversation.
Note that this method does not create a conversation, but restore a previously created conversation from a local storage (database).
Returns VIConversation instance or null if uuid is null.
Parameters
uuid:
String
Conversation UUID
conversationConfig:
Conversation config
lastSequence:
int
Sequence of the last event stored in a local storage (database)
lastUpdateTime:
int
UNIX timestamp that specifies the time of the last event stored in a local storage (database)
createdTime:
int
UNIX timestamp that specifies the time of the conversation creation
Returns
type:
recreateMessage
recreateMessage(String
uuid, String
conversationUuid, String
text, List<Map<String, Object>>
payload, int
sequence = 0)
Recreates a message.
Note that this method does not create a message, but restore a previously created message from a local storage (database).
Returns VIMessage instance or null if uuid or conversationUuid is null.
Parameters
uuid:
String
Universally unique identifier of message
conversationUuid:
String
UUID of the conversation this message belongs to
text:
String
Text of this message
payload:
List<Map<String, Object>>
List of payload objects associated with the message
sequence:
int
OptionalMessage sequence number
Returns
type:
setStatus
Future<VIStatusEvent>
setStatus(bool
online)
Sets the current user status.
Other users (that are subscribed to the user) and other clients (of the current user) can be informed about the status changing via the VIMessenger.onSetStatus
Throws VIException, if operation failed, otherwise returns VIStatusEvent instance. For all possible errors see VIMessagingError
Parameters
online:
bool
Whether the user is available for messaging
Returns
type:
Future<VIStatusEvent>
subscribe
Future<VISubscriptionEvent>
subscribe(List<int>
users)
Subscribes for other user(s) information and status changes.
It is possible to subscribe for any user of the main Voximplant developer account or its child accounts.
Other logged in clients (of the current user) can be informed about the subscription via the VIMessenger.onSubscribe callback. User(s) specified in the 'users' parameter are not informed about the subscription.
Throws VIException, if operation failed, otherwise returns VISubscriptionEvent instance. For all possible errors see VIMessagingError
Parameters
users:
List<int>
List of IM user ids
Returns
type:
Future<VISubscriptionEvent>
unsubscribe
Future<VISubscriptionEvent>
unsubscribe(List<int>
users)
Unsubscribes from other user(s) information and status changes.
It is possible to subscribe for any user of the main Voximplant developer account or its child accounts.
Other logged in clients (of the current user) can be informed about the unsubscription via the VIMessenger.onSubscribe callback. User(s) specified in the 'users' parameter are not informed about the unsubscription.
Throws VIException, if operation failed, otherwise returns VISubscriptionEvent instance. For all possible errors see VIMessagingError
Parameters
users:
List<int>
List of IM user ids
Returns
type:
Future<VISubscriptionEvent>
unsubscribeFromAll
Future<VISubscriptionEvent>
unsubscribeFromAll()
Unsubscribes from all subscriptions.
Other logged in clients (of the current user) can be informed about the unsubscription via the VIMessenger.onSubscribe callback. User(s) specified in the 'users' parameter are not informed about the unsubscription.
Throws VIException, if operation failed, otherwise returns VISubscriptionEvent instance. For all possible errors see VIMessagingError
Returns
type:
Future<VISubscriptionEvent>
Props
me
String?
me
Gets the Voximplant user identifier for the current user, e.g., 'username@appname.accname'
Returns
type:
String?
onCreateConversation
onCreateConversation
Triggered when a new conversation is created with the current user.
Returns
type:
onEditConversation
onEditConversation
Triggered when the properties of a conversation the current user belongs to are modified.
Returns
type:
onEditMessage
onEditMessage
Triggered when a message has been edited.
Returns
type:
onRead
onRead
Triggered when a participant in a conversation mark the event as read.
Returns
type:
onRemoveConversation
onRemoveConversation
Triggered when a conversation the current user belongs to is removed.
Returns
type:
onRemoveMessage
onRemoveMessage
Triggered when a message has been removed from a conversation the current user belongs to.
Returns
type:
onSendMessage
onSendMessage
Triggered when a new message has been sent to a conversation the current user belongs to.
Returns
type:
onSetStatus
onSetStatus
Triggered when an user status has been changed.
Returns
type:
onSubscribe
onSubscribe
Callback for getting notified about new subscriptions.
Returns
type:
onTyping
onTyping
Triggered when some user is typing text in a conversation.
Returns
type:
onUnsubscribe
onUnsubscribe
Callback for getting notified about changes in current subscriptions.
Returns
type: