一、新建好友分组
你可以调用 FriendshipCreateFriendGroup (点击查看详情) 接口新建好友分组。
示例代码如下:
// 创建好友分组,并添加好友进分组FriendGroupInfo param = new FriendGroupInfo{ friendship_create_friend_group_param_name_array = new List<string> { "group_name" }, friendship_create_friend_group_param_identifier_array = new List<string> { "user_id" }};TIMResult res = TencentIMSDK.FriendshipCreateFriendGroup(param, (int code, string desc, List<FriendResult> result, string user_data)=>{ // 处理异步逻辑});
二、删除好友分组
你可以调用 FriendshipDeleteFriendGroup (点击查看详情) 接口删除好友分组。
示例代码如下:
// 删除好友分组List<string> param = new List<string>{ "user_id"};TIMResult res = TencentIMSDK.FriendshipDeleteFriendGroup(param, (int code, string desc, string user_data)=>{ // 处理异步逻辑});
三、重命名好友分组
你可以调用 FriendshipModifyFriendGroup (点击查看详情) 接口重命名好友分组。
示例代码如下:
// 修改好友分组名字FriendshipModifyFriendGroupParam param = new FriendshipModifyFriendGroupParam{ friendship_modify_friend_group_param_name = "old_group_name", friendship_modify_friend_group_param_new_name = "new_group_name"};TIMResult res = TencentIMSDK.FriendshipModifyFriendGroup(param, (int code, string desc, List<FriendResult> result, string user_data)=>{ // 处理异步逻辑});
四、获取好友分组
你可以调用 FriendshipGetFriendGroupList (点击查看详情) 接口获取好友分组列表。
示例代码如下:
// 按分组名字获取好友分组信息List<string> param = new List<string> { "user_id" };TIMResult res = TencentIMSDK.FriendshipGetFriendGroupList(param, (int code, string desc, List<FriendGroupInfo> info_list, string user_data)=>{ // 处理异步逻辑});
五、添加好友到一个分组
你可以调用 FriendshipModifyFriendGroup (点击查看详情) 接口添加好友到一个分组。
示例代码如下:
// 将用户添加到分组中FriendshipModifyFriendGroupParam param = new FriendshipModifyFriendGroupParam{ friendship_modify_friend_group_param_name = "group_name", friendship_modify_friend_group_param_add_identifier_array = new List<string> { "user_id" }};TIMResult res = TencentIMSDK.FriendshipModifyFriendGroup(param, (int code, string desc, List<FriendResult> result, string user_data)=>{ // 处理异步逻辑});
六、从分组中删除某好友
你可以调用 FriendshipModifyFriendGroup (点击查看详情) 从分组中删除某好友。
示例代码如下:
// 将要有从分组中删除FriendshipModifyFriendGroupParam param = new FriendshipModifyFriendGroupParam{ friendship_modify_friend_group_param_name = "group_name", friendship_modify_friend_group_param_delete_identifier_array = new List<string> { "user_id" }};TIMResult res = TencentIMSDK.FriendshipModifyFriendGroup(param, (int code, string desc, List<FriendResult> result, string user_data)=>{ // 处理异步逻辑});