Accepts a friend request.
connection.acceptContactInvite('user1')
Adds a friend.
connection.addContact('user1', 'I am Bob')
Marks conversations.
connection.addConversationMark({
conversations: [{conversationId: 'conversationId', conversationType: 'singleChat'}],
mark: 0,
})
The list of conversations.
The mark to add for the conversations.
Adds a reaction to the message.
connection.addReaction({messageId: 'messageId', action: 'action'})
The message ID.
The reaction to be added to the message. The length is limited to 128 characters.
Adds a contact to the blocklist.
connection.addUsersToBlocklist({name: 'user1'})
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.
Declines a friend request.
connection.declineContactInvite('user1')
Deletes all conversations and all messages in them.
connection.deleteAllMessagesAndConversations()
Deletes the contact.
connection.deleteContact('user1')
Deletes the conversation.
connection.deleteConversation({
channel: 'targetId',
chatType: 'singleChat',
deleteRoam: true
})
The conversation ID: The user ID of the peer user or group ID.
The conversation type:
singleChat
: one-to-one chat;groupChat
: group chat.Whether to delete historical messages on the server during conversation deletion.
true
: Yes;false
: No.Removes a reaction from a message.
connection.deleteReaction({reactionId: 'reactionId'})
The message ID.
The message reaction to delete.
Queries the user attributes.
connection.fetchUserInfoById('user1') | fetchUserInfoById(['user1', 'user2'])
Gets the all contacts.
connection.getAllContacts()
Gets the blocklist.
connection.getBlocklist()
Gets the contact list.
connection.getContacts()
Gets the list of contacts with pagination.
connection.getContactsWithCursor({pageSize:50, cursor: ''})
The position from which to start getting data.
The number of contacts that you expect to get on each page. The value range is [1,50] and the default value is 20
.
Gets the message history.
connection.getHistoryMessages({targetId:'targetId',chatType:'groupChat', pageSize: 20})
The chat type for SDK:
singleChat
: one-to-one chat;groupChat
: group chat;chatRoom
: chat room chat.The starting message ID for this query. The default value is -1, which means to start retrieving from the latest message.
The number of messages to retrieve each time. The default value is 20,The maximum value is 50.
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.up
.Query conditions.
The end timestamp for query. The unit is millisecond.
The user ID of the message sender. This parameter is used only for group chat.
An array of message types for query. If no value is passed in, all message types will be queried.
The start timestamp for query. The unit is millisecond.
The user ID of the other party or the group ID or chat room ID.
Gets the details of a reaction.
getReactionDetail({messageId: 'messageId', reaction: 'reaction', cursor: '', pageSize: 20})
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.
The message ID.
The number of reactions per page. The default value is 20, and the maximum value is 100.
The reactions to retrieve.
Gets the reaction list for the message.
connection.getReactionlist({chatType: 'chatType', messageId: 'messageId'})
The conversation type:
The group ID.
The message ID.
Get the unique IDs of current user on the other devices. The ID is user ID + "/" + resource.
connection.getSelfIdsOnOtherPlatform()
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: ''})
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.
The number of conversations that you expect to get on each page. The value range is [1,50] and the default value is 20
.
Gets the conversations from the server with pagination according to the conversation filter.
connection.getServerConversationsByFilter({pageSize:10, cursor: '',filter: {mark: 0})
The position from which to start getting data.
The conversation filter options.
The conversation mark for query.
The number of conversations to retrieve on each page. The value range is [1,10] and the default value is 10
.
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: ''})
The position from which to start getting data. If you pass in an empty string (''), the SDK retrieves conversations from the latest pinned one.
The number of conversations that you expect to get on each page. The value range is [1,50] and the default value is 20
.
Gets the pinned messages in a conversation with pagination.
connection.getServerPinnedMessages({
conversationId: 'conversationId',
conversationType: 'groupChat',
pageSize: 20,
cursor: ''
})
The conversation ID.
The conversation type.
The position from which to start getting data. For the first call of the method, an empty string ('') is passed in and the SDK returns the list of pinned messages in the descending order of when they are pinned.
The number of pinned messages to retrieve on each page. The value range is [1,50] and the default value is 10
.
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 })
The ID of the message to modify.
The modified message.
Sets whether to pin a conversation.
connection.pinConversation({conversationId:'conversationId',conversationType: 'singleChat', isPinned: boolean})
The conversation ID.
The conversation type.
Whether to pin the conversation:
true
: Yes.false
: No. The conversation is unpinned.Pins a message.
connection.pinMessage({
conversationId: 'conversationId',
conversationType: 'groupChat',
messageId: 'messageId',
})
The conversation ID.
The conversation type.
The ID of the message to be pinned.
Recalls a message.
connection.recallMessage({mid: 'messageId', to: 'user1', type: 'singleChat'})
The chat type for SDK:
singleChat
: one-to-one chat;groupChat
: group chat;chatRoom
: chat room.Custom extension fields.
Whether the message is in the thread.
The ID of the message to be recalled.
The recipient of the message.
The chat type for SDK (deprecated):
Unmarks conversations.
connection.removeConversationMark({
conversations: [{conversationId: 'conversationId', conversationType: 'singleChat'}],
mark: 0,
})
The list of conversations.
The conversation mark to remove.
Unidirectionally deletes historical messages from the server.
connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', beforeTimeStamp: Date.now()})
connection.removeHistoryMessages({targetId: 'userId', chatType: 'singleChat', messageIds: ['messageId']})
The starting timestamp for message deletion. Messages with the timestamp before the specified one will be deleted.
The conversation type:
singleChat
: one-to-one chat;groupChat
: group chat.The ID list of messages to be deleted. A maximum of 20 message IDs can be passed in.
The ID of the peer user or group ID.
Removes contacts from the blocklist.
connection.removeUserFromBlocklist({name: 'user1'})
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.
Reports an inappropriate message.
reportMessage()
The ID of the message to report.
The reason for reporting. You need to type a specific reason.
The type of reporting.
Set contact remark.
setContactRemark({userId: 'userId', remark: 'remark'})
The remark to set.
The ID of the contact to set the remark for.
Unpins a message.
connection.unpinMessage({
conversationId: 'conversationId',
conversationType: 'groupChat',
messageId: 'messageId'
})
The conversation ID.
The conversation type.
The ID of the message to be unpinned.
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')
Modifies the user's attributes.
connection.updateUserInfo({nickname: 'Tom', avatarurl: 'avatarurl', mail: 'abc@gmail,com', ext: JSON.stringify({hobby: 'football'})})
connection.updateUserInfo('nickname', 'Tom')
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'})
The device ID that identifies the device. Custom device IDs are allowed.
The push token, which identifies a device during message push. Custom push tokens are allowed.
The app ID for the push service, which is the senderID for Firebase Cloud Messaging (FCM) and "appId+#+AppKey" for the vivo push service.
Generated using TypeDoc
Contact contains the APIs for contact-related operations.