腾讯云即时通信IMUnity_AI解决方案_同尘科技

即时通信 IM 2年前 (2023-06-13) 浏览 25

功能描述

在某些场景下,您可能需要对好友进行分组,例如分为 “大学同学”、”公司同事” 等,您可以调用以下接口实现。

好友分组

新建好友分组

您可以调用 FriendshipCreateFriendGroup (点击查看详情) 接口新建好友分组。示例代码如下:

// 创建好友分组,并添加好友进分组FriendGroupInfo param = new FriendGroupInfo{  friendship_create_friend_group_param_name_array = new List  {    "group_name"  },  friendship_create_friend_group_param_identifier_array = new List  {    "user_id"  }};TIMResult res = TencentIMSDK.FriendshipCreateFriendGroup(param, (int code, string desc, List result, string user_data)=>{ // 处理异步逻辑});

删除好友分组

您可以调用 FriendshipDeleteFriendGroup (点击查看详情) 接口删除好友分组。示例代码如下:

// 删除好友分组List param = new List{  "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 result, string user_data)=>{ // 处理异步逻辑});

获取好友分组

您可以调用 FriendshipGetFriendGroupList (点击查看详情) 接口获取好友分组列表。示例代码如下:

// 按分组名字获取好友分组信息List param = new List  {    "user_id"  };TIMResult res = TencentIMSDK.FriendshipGetFriendGroupList(param, (int code, string desc, List 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  {    "user_id"  }};TIMResult res = TencentIMSDK.FriendshipModifyFriendGroup(param, (int code, string desc, List 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  {    "user_id"  }};TIMResult res = TencentIMSDK.FriendshipModifyFriendGroup(param, (int code, string desc, List result, string user_data)=>{ // 处理异步逻辑});

交流与反馈

点此进入IM社群,享有专业工程师的支持,解决您的难题

对即时通讯IM解决方案有疑惑?想了解解决方案收费? 联系解决方案专家

腾讯云限时活动1折起,即将结束: 马上收藏

同尘科技为腾讯云授权服务中心,购买腾讯云享受折上折,更有现金返利:同意关联,立享优惠

阿里云解决方案也看看?: 点击对比阿里云的解决方案

- 0人点赞 -

发表点评 (0条)

not found

暂无评论,你要说点什么吗?