Options
All
  • Public
  • Public/Protected
  • All
Menu

Contact contains the APIs for contact-related operations.

Index

Functions

  • acceptContactInvite(this: any, to: string): Promise<void>
  • Accepts a friend request.

    connection.acceptContactInvite('user1')
    

    Parameters

    • this: any
    • to: string

    Returns Promise<void>

  • addContact(this: any, to: string, message?: string): Promise<void>
  • Adds a friend.

    connection.addContact('user1', 'I am Bob')
    

    Parameters

    • this: any
    • to: string
    • Optional message: string

    Returns Promise<void>

  • addReaction(this: any, params: { messageId: string; reaction: string }): Promise<void>
  • Adds a reaction to the message.

    connection.addReaction({messageId: 'messageId', action: 'action'})
    

    Parameters

    • this: any
    • params: { messageId: string; reaction: string }
      • messageId: string

        The message ID.

      • reaction: string

        The reaction to be added to the message. The length is limited to 128 characters.

    Returns Promise<void>

  • addUsersToBlocklist(this: any, options: { name: string | string[] }): Promise<void>
  • Adds a contact to the blocklist.

    connection.addUsersToBlocklist({name: 'user1'})
    

    Parameters

    • this: any
    • options: { name: string | string[] }
      • name: string | string[]

        The user ID. You can type a specific user ID to add a single user to the blocklist or type an array of user IDs, like ["user1","user2"], to add multiple users.

    Returns Promise<void>

  • declineContactInvite(this: any, to: string): Promise<void>
  • Declines a friend request.

    connection.declineContactInvite('user1')
    

    Parameters

    • this: any
    • to: string

    Returns Promise<void>

  • deleteContact(this: any, to: string): Promise<void>
  • Deletes the contact.

    connection.deleteContact('user1')
    

    Parameters

    • this: any
    • to: string

    Returns Promise<void>

  • deleteConversation(this: any, params: { channel: string; chatType: "singleChat" | "groupChat"; deleteRoam: boolean; error?: any; success?: any }): Promise<AsyncResult<DeleteSessionResult>>
  • Deletes the conversation.

    connection.deleteConversation({
    channel: 'targetId',
    chatType: 'singleChat',
    deleteRoam: true
    })

    Parameters

    • this: any
    • params: { channel: string; chatType: "singleChat" | "groupChat"; deleteRoam: boolean; error?: any; success?: any }
      • channel: string

        The conversation ID: The user ID of the peer user or group ID.

      • chatType: "singleChat" | "groupChat"

        The conversation type:

        • singleChat: one-to-one chat;
        • groupChat: group chat.
      • deleteRoam: boolean

        Whether to delete historical messages on the server during conversation deletion.

        • true: Yes;
        • false: No.
      • error?:function
      • success?:function

    Returns Promise<AsyncResult<DeleteSessionResult>>

  • deleteReaction(this: any, params: { messageId: string; reaction: string }): Promise<void>
  • Removes a reaction from a message.

    connection.deleteReaction({reactionId: 'reactionId'})
    

    Parameters

    • this: any
    • params: { messageId: string; reaction: string }
      • messageId: string

        The message ID.

      • reaction: string

        The message reaction to delete.

    Returns Promise<void>

  • getBlocklist(this: any, params?: { error?: any; success?: any }): Promise<AsyncResult<UserId[]>>
  • Gets the blocklist.

    connection.getBlocklist()
    

    Parameters

    Returns Promise<AsyncResult<UserId[]>>

  • getChatToken(this: any, agoraToken: string): Promise<any>
  • Parameters

    • this: any
    • agoraToken: string

    Returns Promise<any>

  • getContacts(this: any, params?: { error?: any; success?: any }): Promise<AsyncResult<UserId[]>>
  • getHistoryMessages(this: any, options: { chatType?: "singleChat" | "groupChat"; cursor?: null | string | number; pageSize?: number; searchDirection?: "down" | "up"; searchOptions?: { endTime?: number; from?: string; msgTypes?: ("audio" | "img" | "video" | "file" | "combine" | "txt" | "cmd" | "custom" | "loc")[]; startTime?: number }; targetId: string; fail?: any; success?: any }): Promise<HistoryMessages>
  • Gets the message history.

    connection.getHistoryMessages({targetId:'targetId',chatType:'groupChat', pageSize: 20})
    

    Parameters

    • this: any
    • options: { chatType?: "singleChat" | "groupChat"; cursor?: null | string | number; pageSize?: number; searchDirection?: "down" | "up"; searchOptions?: { endTime?: number; from?: string; msgTypes?: ("audio" | "img" | "video" | "file" | "combine" | "txt" | "cmd" | "custom" | "loc")[]; startTime?: number }; targetId: string; fail?: any; success?: any }
      • Optional chatType?: "singleChat" | "groupChat"

        The chat type for SDK:

        • singleChat: one-to-one chat;
        • groupChat: group chat;
        • (Default)singleChat: No.
      • Optional cursor?: null | string | number

        The starting message ID for this query. The default value is -1, which means to start retrieving from the latest message.

      • Optional pageSize?: number

        The number of messages to retrieve each time. The default value is 20,The maximum value is 50.

      • Optional searchDirection?: "down" | "up"

        Whether to select pull history messages in positive order(Pull message from the oldest to the latest).

        • up: means searching from the newer messages to the older messages.
        • down: means searching from the older messages to the newer messages.
        • (Default)up.
      • Optional searchOptions?: { endTime?: number; from?: string; msgTypes?: ("audio" | "img" | "video" | "file" | "combine" | "txt" | "cmd" | "custom" | "loc")[]; startTime?: number }

        Query conditions.

        • Optional endTime?: number

          The end timestamp for query. The unit is millisecond.

        • Optional from?: string

          The user ID of the message sender. This parameter is used only for group chat.

        • Optional msgTypes?: ("audio" | "img" | "video" | "file" | "combine" | "txt" | "cmd" | "custom" | "loc")[]

          An array of message types for query. If no value is passed in, all message types will be queried.

        • Optional startTime?: number

          The start timestamp for query. The unit is millisecond.

      • targetId: string

        The user ID of the other party or the group ID.

      • fail?:function
      • success?:function

    Returns Promise<HistoryMessages>

  • Gets the details of a reaction.

    getReactionDetail({messageId: 'messageId', reaction: 'reaction', cursor: '', pageSize: 20})
    

    Parameters

    • this: any
    • params: { cursor?: string; messageId: string; pageSize?: number; reaction: string }
      • Optional cursor?: string

        The cursor that specifies where to start to get data. If there will be data on the next page, this method will return the value of this field to indicate the position to start to get data of the next page. If it is null, the data of the first page will be retrieved.

      • messageId: string

        The message ID.

      • Optional pageSize?: number

        The number of reactions per page. The default value is 20, and the maximum value is 100.

      • reaction: string

        The reactions to retrieve.

    Returns Promise<AsyncResult<GetReactionDetailResult>>

  • getReactionlist(this: any, params: { chatType: "singleChat" | "groupChat"; groupId?: string; messageId: string | string[] }): Promise<AsyncResult<GetReactionListResult[]>>
  • Gets the reaction list for the message.

    connection.getReactionlist({chatType: 'chatType', messageId: 'messageId'})
    

    Parameters

    • this: any
    • params: { chatType: "singleChat" | "groupChat"; groupId?: string; messageId: string | string[] }
      • chatType: "singleChat" | "groupChat"

        The conversation type:

        • singleChat;
        • groupChat;
      • Optional groupId?: string

        The group ID.

      • messageId: string | string[]

        The message ID.

    Returns Promise<AsyncResult<GetReactionListResult[]>>

  • Gets the list of conversations from the server with pagination.

    The SDK returns the list of conversations in the reverse chronological order of their active time (the timestamp of the last message).

    If there is no message in the conversation, the SDK retrieves the list of conversations in the reverse chronological order of their creation time.

    connection.getServerConversations({pageSize:50, cursor: ''})
    

    Parameters

    • this: any
    • params: { cursor?: string; pageSize?: number }
      • Optional cursor?: string

        The position from which to start getting data. If you set cursor to an empty string (''), the SDK retrieves conversations from the latest active one.

      • Optional pageSize?: number

        The number of conversations that you expect to get on each page. The value range is [1,50] and the default value is 20.

    Returns Promise<AsyncResult<ServerConversations>>

  • Get the list of pinned conversations from the server with pagination.

    The SDK returns the pinned conversations in the reverse chronological order of their pinning.

    connection.getServerPinnedConversations({pageSize:50, cursor: ''})
    

    Parameters

    • this: any
    • params: { cursor?: string; pageSize?: number }
      • Optional cursor?: string

        The position from which to start getting data. If you pass in an empty string (''), the SDK retrieves conversations from the latest pinned one.

      • Optional pageSize?: number

        The number of conversations that you expect to get on each page. The value range is [1,50] and the default value is 20.

    Returns Promise<AsyncResult<ServerConversations>>

  • Modifies a message on the server.

    This method can only modify a text message in one-to-one chats or group chats, but not in chat rooms.

    Upon a message modification, the callback onModifiedMessage will be received by the message recipient(s) and in multi-device login scenarios.


    const textMessage = WebIM.message.create({
    type: "txt",
    msg: "message content",
    to: "username",
    chatType: "singleChat",
    });

    connection.modifyMessage({ messageId: 'messageId', message: textMessage })

    Parameters

    • this: any
    • option: { messageId: string; modifiedMessage: Message.TextMsgBody }
      • messageId: string

        The ID of the message to modify.

      • modifiedMessage: Message.TextMsgBody

        The modified message.

    Returns Promise<ModifyMsgResult>

  • pinConversation(this: any, params: { conversationId: string; conversationType: "singleChat" | "groupChat"; isPinned: boolean }): Promise<AsyncResult<PinConversation>>
  • Sets whether to pin a conversation.

    connection.pinConversation({conversationId:'conversationId',conversationType: 'singleChat', isPinned: boolean})
    

    Parameters

    • this: any
    • params: { conversationId: string; conversationType: "singleChat" | "groupChat"; isPinned: boolean }
      • conversationId: string

        The conversation ID.

      • conversationType: "singleChat" | "groupChat"

        The conversation type.

      • isPinned: boolean

        Whether to pin the conversation:

        • true: Yes.
        • false: No. The conversation is unpinned.

    Returns Promise<AsyncResult<PinConversation>>

  • recallMessage(this: any, option: { chatType?: "singleChat" | "groupChat" | "chatRoom"; isChatThread?: boolean; mid: string; to: string; type?: "chat" | "groupchat" | "chatroom"; fail?: any; success?: any }): Promise<ContactType.SendMsgResult>
  • Recalls a message.

    connection.recallMessage({mid: 'messageId', to: 'user1', type: 'singleChat'})
    

    Parameters

    • this: any
    • option: { chatType?: "singleChat" | "groupChat" | "chatRoom"; isChatThread?: boolean; mid: string; to: string; type?: "chat" | "groupchat" | "chatroom"; fail?: any; success?: any }
      • Optional chatType?: "singleChat" | "groupChat" | "chatRoom"

        The chat type for SDK:

        • singleChat: one-to-one chat;
        • groupChat: group chat;
        • chatRoom: chat room.
      • Optional isChatThread?: boolean

        Whether the message is in the thread.

      • mid: string

        The ID of the message to be recalled.

      • to: string

        The recipient of the message.

      • Optional type?: "chat" | "groupchat" | "chatroom"

        The chat type for SDK (deprecated):

        • chat: one-to-one chat;
        • groupchat: group chat;
        • chatroom: chat room.
      • fail?:function
      • success?:function

    Returns Promise<ContactType.SendMsgResult>

  • removeHistoryMessages(this: any, options: { beforeTimeStamp?: number; chatType: "singleChat" | "groupChat"; messageIds?: string[]; targetId: string }): Promise<void>
  • Unidirectionally deletes historical messages from the server.

    connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', beforeTimeStamp: Date.now()})

    connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', messageIds: ['messageId']})

    Parameters

    • this: any
    • options: { beforeTimeStamp?: number; chatType: "singleChat" | "groupChat"; messageIds?: string[]; targetId: string }
      • Optional beforeTimeStamp?: number

        The starting timestamp for message deletion. Messages with the timestamp before the specified one will be deleted.

      • chatType: "singleChat" | "groupChat"

        The conversation type:

        • singleChat: one-to-one chat;
        • groupChat: group chat.
      • Optional messageIds?: string[]

        The ID list of messages to be deleted. A maximum of 20 message IDs can be passed in.

      • targetId: string

        The ID of the peer user or group ID.

    Returns Promise<void>

  • removeUserFromBlocklist(this: any, options: { name: string | string[] }): Promise<void>
  • Removes contacts from the blocklist.

    connection.removeUserFromBlocklist({name: 'user1'})
    

    Parameters

    • this: any
    • options: { name: string | string[] }
      • name: string | string[]

        The user ID. You can type a specific user ID to remove a single user from the blocklist or type an array of user IDs, like ["user1","user2"], to remove multiple users.

    Returns Promise<void>

  • reportMessage(this: any, params: { messageId: string; reportReason: string; reportType: string }): Promise<void>
  • Reports an inappropriate message.

    reportMessage()
    

    Parameters

    • this: any
    • params: { messageId: string; reportReason: string; reportType: string }
      • messageId: string

        The ID of the message to report.

      • reportReason: string

        The reason for reporting. You need to type a specific reason.

      • reportType: string

        The type of reporting.

    Returns Promise<void>

  • Changes the nickname shown when the message push notification is received. This nickname is specified during user registration and it's not the same as the nickname attribute of the user.

    connection.updateCurrentUserNick('Tom')
    

    Parameters

    • this: any
    • nick: string

    Returns Promise<AsyncResult<BaseUserInfo[]>>

  • uploadPushToken(this: any, params: { deviceId: string; deviceToken: string; notifierName: string; error?: any; success?: any }): Promise<AsyncResult<UploadTokenResult>>
  • Uploads the token to the server. This method is used when the SDK is used on a native client on which a third-party push service is to be integrated.

    connection.uploadPushToken({deviceId: 'deviceId', deviceToken: 'deviceToken', notifierName: 'notifierName'})
    

    Parameters

    • this: any
    • params: { deviceId: string; deviceToken: string; notifierName: string; error?: any; success?: any }
      • deviceId: string

        The device ID that identifies the device. Custom device IDs are allowed.

      • deviceToken: string

        The push token, which identifies a device during message push. Custom push tokens are allowed.

      • notifierName: string

        The app ID for the push service, which is the senderID for Firebase Cloud Messaging (FCM) and "appId+#+AppKey" for the vivo push service.

      • error?:function
      • success?:function

    Returns Promise<AsyncResult<UploadTokenResult>>

Generated using TypeDoc