// 获取好友列表TIMResult res = TencentIMSDK.FriendshipGetFriendProfileList((int code, string desc, List<FriendProfile> profile_list, string user_data)=>{// 处理异步逻辑});
// 添加双向好友FriendshipAddFriendParam param = new FriendshipAddFriendParam{friendship_add_friend_param_identifier = "friend_userid",friendship_add_friend_param_friend_type = TIMFriendType.FriendTypeBoth,friendship_add_friend_param_remark = "nickname",friendship_add_friend_param_add_wording = "greeting"};TIMResult res = TencentIMSDK.FriendshipAddFriend(param, (int code, string desc, FriendResult result, string user_data)=>{// 处理异步逻辑});
SetOnAddFriendCallback 设置关系链监听器。ProfileModifySelfUserProfile 函数里的 user_profile_item_add_permission (点击查看详情) 字段设置为加好友不需要验证(kTIMProfileAddPermission_AllowAny)。FriendshipAddFriend 申请添加 B 为好友即可添加成功。添加成功后,按照申请参数 FriendshipAddFriendParam 中 friendship_add_friend_param_friend_type 的设置有两种情况:TIMFriendType.FriendTypeBoth) ,则用户 A 和 B 都会收到 OnAddFriendCallback (点击查看详情) 回调;TIMFriendType.FriendTypeSignle),则只有用户 A 收到 OnAddFriendCallback 回调。SetOnAddFriendCallback 设置关系链监听。ProfileModifySelfUserProfile 函数里的 user_profile_item_add_permission 字段设置为加好友需要验证(kTIMProfileAddPermission_NeedConfirm)。FriendshipAddFriend 申请添加 B 为好友,接口的成功回调参数中 code 返回 30539,表示需要等待用户 B 的验证。SetFriendAddRequestCallback 的回调,可以选择接受或者拒绝:FriendshipHandleFriendAddRequest (点击查看详情) 接受好友请求。如果参数接受类型为仅同意加单向好友(TIMFriendResponseAction.ResponseActionAgree)时:OnAddFriendCallback 回调,说明单向加好友成功。FriendApplicationListDeletedCallback (点击查看详情) 回调,此时 B 成为 A 的好友,但 A 仍不是 B 的好友。FriendshipHandleFriendAddRequest 接受好友请求,如果参数接受类型为同意加双向好友时(TIMFriendResponseAction.ResponseActionAgreeAndAdd),A 和 B 都会收到 OnAddFriendCallback 回调,说明互相加好友成功。FriendshipHandleFriendAddRequest 传参 TIMFriendResponseAction.ResponseActionReject 拒绝好友请求,双方都会收到 FriendApplicationListDeletedCallback 回调。// 删除双向好友FriendshipDeleteFriendParam param = new FriendshipDeleteFriendParam{friendship_delete_friend_param_friend_type = TIMFriendType.FriendTypeBoth,friendship_delete_friend_param_identifier_array = new List<string>{"user_id"}};TIMResult res = TencentIMSDK.FriendshipDeleteFriend(param, (int code, string desc, FriendResult result, string user_data)=>{// 处理异步逻辑});
// 检测好友是否有双向(单向)好友关系。FriendshipCheckFriendTypeParam param = new FriendshipCheckFriendTypeParam{friendship_check_friendtype_param_check_type = TIMFriendType.FriendTypeBoth,friendship_check_friendtype_param_identifier_array = new List<string>{"user_id"}};TIMResult res = TencentIMSDK.FriendshipCheckFriendType(param, (int code, string desc, List<FriendshipCheckFriendTypeResult> result_list, string user_data)=>{// 处理异步逻辑});
文档反馈