please select
  • UIKit
  • SDK
  • Server APIs
Chat/
SDK/
Web/
User Profile and Relationship Chain/
SDK
  • Install Chat SDK
  • Initialize Chat SDK
  • Login and Logout
  • Client APIs
  • Changelog
  • Message
    • Overview
    • Send a Message
    • Receive a Message
    • Historical Message
    • Forward Messages
    • Modify a Message
    • Delete Messages
    • Clear History Message
    • Recall a Message
    • Send an Online Message
    • Message Read Receipt
    • Query Messages
    • Targeted Group Message
    • Do not Notify
    • Key-Value Extensions
    • Translation
  • Conversation
    • Overview
    • Conversation List
    • Get Conversations
    • Unread Count
    • Pin Conversations
    • Delete Conversations
    • Mark
    • Conversation Group
  • Group
    • Overview
    • Group Management
    • Group Profile
    • Group Member Management
    • Group Member Profile
    • Custom Group Attribute
    • Group Counter
  • Community Topic
    • Community Management
  • User Profile and Relationship Chain
    • User Profile
    • User Status
    • Friend Management
    • Friend Group
    • Block List
  • Guideline for Beginners
  • Console Guide
    • Creating and Upgrading an Application
    • Basic Configuration
    • Feature Configuration
    • Account Management
    • Group Management
    • Webhook Configuration
  • Product Introduction
    • Message Management
      • One-to-One Message
      • Message Storage
      • Offline Push
      • Group Message
      • Message Formats
    • Account System
      • Login Authentication
      • Online Status Management
    • Group Related
      • Group System
      • Group Management
    • User Profile and Relationship Chain
      • Profile Management
      • Relationship Chain Management
  • Purchase Guide
    • Billing Overview
    • Pricing
  • Error Codes

Friend Group

Feature Description

To group friends into categories such as "Classmates at university" and "Coworkers", call the following APIs.

Creating a friend group

API
chat.createFriendGroup(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
name
String
List name
userIDList
Array
List of userID values of the friends to be added to the group
Returned value
Promise
Sample
let promise = chat.createFriendGroup({
name: 'My friend group 1',
userIDList: ['user0','user1']
});
promise.then(function(imResponse) {
const { friendGroup,failureUserIDList } = imResponse;
// friendGroup - Friend list instance
// failureUserIDList - List of the `userID` values failed to be added
// When the friend group is successfully created
// the SDK triggers the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
}).catch(function(imError) {
console.warn('getFriendGroupInfo error:', imError); // Failed to obtain the information
});

Deleting a friend group

API
chat.deleteFriendGroup(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
name
String
group name
Returned value
Promise
Sample
let promise = chat.deleteFriendGroup({
name: 'My friend group 1',
});
promise.then(function(imResponse) {
console.log(imResponse.data); // Friend list instance
// When the friend group is successfully deleted
// the SDK triggers the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
}).catch(function(imError) {
console.warn('deleteFriendGroup error:', imError); // Failed to obtain the information
});

Renaming a friend group

API
chat.renameFriendGroup(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
oldName
String
Old group name
newName
String
New group name
Returned value
Promise
Sample
let promise = chat.renameFriendGroup({
oldName: 'Friends',
newName: 'Besties'
});
promise.then(function(imResponse) {
console.log(imResponse.data); // FriendGroup instance
// When the name of a friend group is changed successfully
// the SDK triggers the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
}).catch(function(imError) {
console.warn('updateMyProfile error:', imError);
});

Getting a friend group

The friend groups cached in the SDK can be obtained. When a friend group is updated, the SDK will deliver the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
API
chat.getFriendGroupList();
Returned value
Promise
Sample
let promise = chat.getFriendGroupList();
promise.then(function(imResponse) {
const friendGroupList = imResponse.data; // Friend list
}).catch(function(imError) {
console.warn('getFriendGroupList error:', imError); // Failed to obtain the friend group
});

Adding a friend to a list

API
chat.addToFriendGroup(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
name
String
Group name
userIDList
Array
List of userID values of the friends to be added
Returned value
Promise
Sample
let promise = chat.addToFriendGroup({
name: 'My friend group 1',
userIDList: ['user1','user2'],
});
promise.then(function(imResponse) {
const { friendGroup, failureUserIDList } = imResponse.data;
// friendGroup - Friend list instance
// failureUserIDList - List of the `userID` values failed to be added
// When the friends are successfully added to the friend group,
// the SDK triggers the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
}).catch(function(imError) {
console.warn('addToFriendGroup error:', imError); // Failed to obtain the information
});

Removing a friend from a list

API
chat.removeFromFriendGroup(options);
Parameter
The options parameter is of the Object type. It contains the following attribute values:
Name
Type
Description
name
String
Group name
userIDList
Array
List of userID values of the friends to be removed
Returned value
Promise
Sample
let promise = chat.removeFromFriendGroup({
name: 'My friend group 1',
userIDList: ['user1','user2'],
});
promise.then(function(imResponse) {
const { friendGroup, failureUserIDList } = imResponse.data;
// friendGroup - Friend list instance
// failureUserIDList - List of the `userID` values failed to be added
// When the friends are successfully removed from the friend group
// the SDK triggers the TencentCloudChat.EVENT.FRIEND_GROUP_LIST_UPDATED event.
}).catch(function(imError) {
console.warn('addToFriendGroup error:', imError); // Failed to obtain the information
});