Rate this page:

Messenger

Messenger class is used to control messaging functions. Can't be instantiated directly (singleton), please use getMessengeror Messaging.getto get the class instance.

Methods

createConversation

Copy URL
createConversation(participants: 

ConversationParticipant[]

,
title:

string

,
direct:

boolean

,
publicJoin:

boolean

,
uber:

boolean

,
customData:

object

):

Promise<CreateConversationEvent>

Create a new conversation. The creator of any conversation by default:

Parameters

Returns

createConversationFromCache

Copy URL
createConversationFromCache(cachedConversation: 

SerializedConversation

):

Conversation

Restore the conversation from cache that was previously serialized by the Conversation.toCachemethod.

Parameters

Returns

createMessageFromCache

Copy URL
createMessageFromCache(cachedMessage: 

SerializedMessage

):

Message

Restore a Messagefrom its serialisation previously created by the Message.toCachemethod.

Parameters

Returns

editUser

Copy URL
editUser(customData: 

object

,
privateCustomData:

object

):

Promise<EditUserEvent>

Edit the current user information. Triggers the MessengerEvents.EditUserevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • customData:

    object

    Optional

    Public custom data available to any user. If null or undefined, previously set custom data will not be changed. If an empty object, previously set custom data will be removed.

  • privateCustomData:

    object

    Optional

    Private custom data available only to the current user. If null or undefined, previously set custom data will not be changed. If an empty object, previously set custom data will be removed.

Returns

getConversation

Copy URL
getConversation(uuid: 

string

):

Promise<GetConversationEvent>

Get a conversation by its UUID. Triggers the MessengerEvents.GetConversationevent. To get the result, use one of these options:

Parameters

  • uuid:

    string

Returns

getConversations

Copy URL
getConversations(conversations: 

string[]

):

Promise<GetConversationEvent[]>

Get the multiple conversations by an array of UUIDs. Maximum 30 conversation. Triggers multiple MessengerEvents.GetConversationevents. To get the result, use one of these options:

Parameters

  • conversations:

    string[]

    Array of conversation UUIDs. Maximum 30 conversations.

Returns

getMe

Copy URL
getMe(): 

string

Get the Voximplant user identifier for the current user (e.g. 'username@appname.accname').

Returns

  • type:

    string

getMyId

Copy URL
getMyId(): 

Promise<number>

Get the Messaging user id for the current user. Triggers the MessengerEvents.GetUserevent. To get the result, use one of these options:

Returns

  • type:

    Promise<number>

getPublicConversations

Copy URL
getPublicConversations(): 

Promise<GetPublicConversationsEvent>

Get UUIDs of all public conversations (see Conversation.publicJoin created by the current user, other users of the same child account or any user of the main Voximplant developer account. Triggers еру MessengerEvents.GetPublicConversationsevents. To get tрe result, use one of these options:

Returns

getSubscriptionList

Copy URL
getSubscriptionList(): 

Promise<GetSubscriptionListEvent>

Get the list of users the current user is subscribed to. Triggers the MessengerEvents.GetSubscriptionListevent. To get the result, use one of these options:

Returns

getUser

Copy URL
getUser(userName: 

string

):

Promise<GetUserEvent>

Get Userinformation for the user specified by the Voximplant user name (e.g. 'username@appname.accname'). It's possible to get any user of the main Voximplant developer account or its child accounts. Triggers the MessengerEvents.GetUserevent. To get the result, use one of these options:

Parameters

  • userName:

    string

Returns

getUserById

Copy URL
getUserById(userId: 

number

):

Promise<GetUserEvent>

Get Userinformation for the user specified by the Messaging user id. It's possible to get any user of the main Voximplant developer account or its child accounts. Triggers the MessengerEvents.GetUserevent. To get the result, use one of these options:

Parameters

  • userId:

    number

    Messaging user id

Returns

getUsers

Copy URL
getUsers(users: 

string[]

):

Promise<GetUserEvent[]>

Get Userinformation for the users specified by an array of the Voximplant user names (e.g. 'username@appname.accname'). Maximum 50 users. It's possible to get any users of the main Voximplant developer account or its child accounts. Triggers multiple MessengerEvents.GetUserevents. To get the result, use one of these options:

Parameters

  • users:

    string[]

    Array of the Voximplant user names (e.g. 'username@appname.accname'). Maximum 50 users.

Returns

getUsersById

Copy URL
getUsersById(userIds: 

number[]

):

Promise<GetUserEvent[]>

Get Userinformation for the users specified by an array of Messaging user ids. Maximum 50 users. It's possible to get any users of the main Voximplant developer account or its child accounts. Triggers multiple MessengerEvents.GetUserevents. To get the result, use one of these options:

Parameters

  • userIds:

    number[]

Returns

joinConversation

Copy URL
joinConversation(uuid: 

string

):

Promise<EditConversationEvent>

Add the current user to the conversation specified by the UUID. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • uuid:

    string

    Universally Unique Identifier of the conversation

Returns

leaveConversation

Copy URL
leaveConversation(uuid: 

string

):

Promise<EditConversationEvent>

Remove the current user from the conversation specified by the UUID. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • uuid:

    string

    Universally Unique Identifier of the conversation

Returns

manageNotification

Copy URL
manageNotification(notifications: 

MessengerEvents[]

):

Promise<EditUserEvent>

Manage push notifications on Messenger events for the current user. Only subscriptions to the MessengerEvents.CreateConversation MessengerEvents.SendMessageand MessengerEvents.EditMessageevents are available. \nNote that you need to set up push notifications to use this method. You'll find all the setup steps in our Push Notifications tutorial. Triggers the MessengerEvents.EditConversationevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

Returns

off

Copy URL
off(event: 

MessengerEvents

,
handler:

Function

):

void

Remove a handler for one of the MessengerEvents If a number of events has the same function as a handler, the method can be called multiple times with the same handler argument.

Parameters

Returns

  • type:

    void

on

Copy URL
on(event: 

MessengerEvents

,
handler:

Function

):

void

Register a handler for any of the MessengerEvents One event can have more than one handler. Handlers are executed in the order of registration. Use the Messenger.offmethod to remove a handler.

Parameters

Returns

  • type:

    void

setStatus

Copy URL
setStatus(online: 

boolean

):

Promise<SetStatusEvent>

Set the current user presence status. Triggers the MessengerEvents.SetStatusevent for all parties of the conversation (online participants and logged in clients) which are subscribed on this user. To get the result, use one of these options:

Parameters

  • online:

    boolean

    True if the user is available for messaging.

Returns

subscribe

Copy URL
subscribe(users: 

number[]

):

Promise<SubscribeEvent>

Subscribe for other user(s) information and status changes. It's possible to subscribe for any user of the main Voximplant developer account or its child accounts. Triggers the MessengerEvents.Subscribeevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • users:

    number[]

    Array of Messaging user ids.

Returns

unsubscribe

Copy URL
unsubscribe(users: 

number[]

,
all:

boolean

):

Promise<UnsubscribeEvent>

Unsubscribe from other user(s) information and status changes. Triggers the MessengerEvents.Unsubscribeevent for all parties of the conversation (online participants and logged in clients). To get the result, use one of these options:

Parameters

  • users:

    number[]

    Array of Messaging user ids.

  • all:

    boolean

    Optional

    If true, an array of user ids is ignored and the current user is unsubscribed from all the conversation users.

Returns