ВОЙТИ

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

createConversation(participants: Array<ConversationParticipant>, title: string, direct: boolean, publicJoin: boolean, uber: boolean, customData: object): Promise<CreateConversationEvent>

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

  • is an owner (see ConversationParticipant.isOwner)
  • can write messages
  • can edit and remove own and other participants' messages
  • can manage conversation participants Triggers either the MessengerEvents.CreateConversation event on for all parties of the conversation (online participants and logged in clients) which are in 'participants' array. To get the result, use one of these options:
  • Subscribe to the MessengerEvents.CreateConversation event and provide a handler consuming an object with the EventHandlers.CreateConversationEvent interface as a parameter. Remember that MessengerEvents.CreateConversation may be triggered by another user , so check the 'initiator' field.
  • Handle the returned promise. Though you still need to listen to MessengerEvents.CreateConversation event to handle events from other parties. Rejects to a Messaging.MessengerError if
  • at least one user in array of participants does not exist or is not a user of the main Voximplant developer account or its child accounts,
  • the specified parameters are contradicting (e.g. 'direct' and 'publicJoin' are both true).

Parameters

Returns

createConversationFromCache

createConversationFromCache(cachedConversation: SerializedConversation): Conversation

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

Parameters

Returns

createMessageFromCache

createMessageFromCache(cachedMessage: SerializedMessage): Message

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

Parameters

Returns

editUser

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

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

getConversations(conversations: Array<string>): Promise<Array<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:

    Array<string>

    Array of conversation UUIDs. Maximum 30 conversations.

Returns

getMe

getMe(): string

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

Returns

  • Return:

    string

getMyId

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

getPublicConversations

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

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

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

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

getUsers(users: Array<string>): Promise<Array<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:

    Array<string>

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

Returns

getUsersById

getUsersById(userIds: Array<number>): Promise<Array<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

Returns

joinConversation

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

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

manageNotification(notifications: Array<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

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

  • Return:

    void

on

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

  • Return:

    void

setStatus

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

subscribe(users: Array<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:

    Array<number>

    Array of Messaging user ids.

Returns

unsubscribe

unsubscribe(users: Array<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:

    Array<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