FriendshipGetFriendProfileList API (details) to get contacts.// Obtain the contactsTIMResult res = TencentIMSDK.FriendshipGetFriendProfileList((int code, string desc, List<FriendProfile> profile_list, string user_data)=>{// Process the async logic});
// Add a two-way friendFriendshipAddFriendParam 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)=>{// Process the async logic});
SetOnAddFriendCallback to set the contacts listener.kTIMProfileAddPermission_AllowAny) through the user_profile_item_add_permission field (details) in the ProfileModifySelfUserProfile function.FriendshipAddFriend, after which the friendship_add_friend_param_friend_type of the FriendshipAddFriendParam request parameter can be set to either value as needed:TIMFriendType.FriendTypeBoth (two-way friend), both users A and B will receive the OnAddFriendCallback callback (details).TIMFriendType.FriendTypeSignle (one-way friend), only user A will receive the OnAddFriendCallback callback.SetOnAddFriendCallback to set the contacts listener.kTIMProfileAddPermission_NeedConfirm) through the user_profile_item_add_permission field in the ProfileModifySelfUserProfile function.FriendshipAddFriend to request to add user B as a friend. The code parameter in the callback for successful API call returns 30539, indicating that the request needs to be approved by user B.SetFriendAddRequestCallback callback and can accept or reject the request.FriendshipHandleFriendAddRequest API (details) to accept the friend request. If the type is TIMFriendResponseAction.ResponseActionAgree (one-way friend):OnAddFriendCallback callback, indicating that the one-way friend was added successfully.FriendApplicationListDeletedCallback callback (details). At this point, user B has become a friend of user A, but not vice versa.FriendshipHandleFriendAddRequest to accept the friend request. If the type is TIMFriendResponseAction.ResponseActionAgreeAndAdd (two-way friend), both users A and B will receive the OnAddFriendCallback callback, indicating that they added each other as a friend successfully.FriendshipHandleFriendAddRequest and passes in the TIMFriendResponseAction parameter to reject the friend request, and both users will receive the FriendApplicationListDeletedCallback callback.// Two-way deletionFriendshipDeleteFriendParam 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)=>{// Process the async logic});
// Check whether the friend relationship is one-way or two-wayFriendshipCheckFriendTypeParam 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)=>{// Process the async logic});
Feedback