Rate this page:

Messenger

Messenger class is used to control messaging functions. Can't be instantiated directly (singleton), please use getMessenger or Messaging.get to 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.toCache method.

Parameters

Returns

createMessageFromCache

Copy URL
createMessageFromCache(cachedMessage: 

SerializedMessage

):

Message

Restore a Message from its serialisation previously created by the Message.toCache method.

Parameters

Returns

editUser

Copy URL
editUser(customData: 

Object

,
privateCustomData:

Object

):

Promise<EditUserEvent>

Edit the current user information. Triggers the MessengerEvents.EditUser event 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.GetConversation event. 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.GetConversation events. 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.GetUser event. 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.GetPublicConversations events. 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.GetSubscriptionList event. To get the result, use one of these options:

Returns

getUser

Copy URL
getUser(userName: 

string

):

Promise<GetUserEvent>

Get User information 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.GetUser event. To get the result, use one of these options:

Parameters

  • userName:

    string

Returns

getUserById

Copy URL
getUserById(userId: 

number

):

Promise<GetUserEvent>

Get User information 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.GetUser event. 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 User information 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.GetUser events. 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 User information 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.GetUser events. 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.EditConversation event 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.EditConversation event 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.SendMessage and MessengerEvents.EditMessage events 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.EditConversation event 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.off method 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.SetStatus event 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.Subscribe event 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.Unsubscribe event 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