followUser
API to follow specified users.V2TimValueCallback<List<V2TimFollowOperationResult>> followResults = await friendshipManager.followUser(userIDList: ['user1']);if (followResults.code == 0) {// Follow users successfullyfollowResults.data?.forEach((element) {element?.userID;element?.resultCode;element.resultInfo;});}
unfollowUser
API to unfollow the specified users.V2TimValueCallback<List<V2TimFollowOperationResult>> unfollowResults = await friendshipManager.unFollowUser(userIDList: ['user1']);if (unfollowResults.code == 0) {// Unfollow users successfullyunfollowResults.data?.forEach((element) {element?.userID; // User IDelement?.resultCode; // Operation result codeelement?.resultInfo; // Operation result information});}
getMyFollowingList
API to pull the list of users you are following.V2TimValueCallback<V2TimUserInfoResult> userInfoListRes = await friendshipManager.getMyFollowingList(nextCursor: "");if (userInfoListRes.code == 0) {// Get following list successfullyuserInfoListRes.data?.nextCursor; // The next cursor for paging pulluserInfoListRes.data?.userFullInfoList?.forEach((element) {element?.userID; // User IDelement?.nickName; // User nick nameelement?.faceUrl; // User avatar urlelement?.selfSignature; // User signatureelement?.gender; // User genderelement?.allowType; // User option for allowing others to add friendselement?.customInfo; // User coustom infoelement?.role; // User roleelement?.level; // User levelelement?.birthday; // User birthday});}
getMyFollowersList
API to fetch your own list of follower users.V2TimValueCallback<V2TimUserInfoResult> userInfoListRes = await friendshipManager.getMyFollowersList
(nextCursor: "");if (userInfoListRes.code == 0) {// Get followers list successfullyuserInfoListRes.data?.nextCursor; // The next cursor for paging pulluserInfoListRes.data?.userFullInfoList?.forEach((element) {element?.userID; // User IDelement?.nickName; // User nick nameelement?.faceUrl; // User avatar urlelement?.selfSignature; // User signatureelement?.gender; // User genderelement?.allowType; // User option for allowing others to add friendselement?.customInfo; // User coustom infoelement?.role; // User roleelement?.level; // User levelelement?.birthday; // User birthday});}
nextCursor
parameter of the API with ""
. After a successful callback, if the returned nextCursor
is not ""
, you can input this value to fetch again, until nextCursor
returns ""
, indicating that the fetch is complete.getMutualFollowersList
API to pull the list of users who mutually follow each other (Users who mutually follow can find each other in their following and followers lists).V2TimValueCallback<V2TimUserInfoResult> userInfoListRes = await friendshipManager.getMutualFollowersList
(nextCursor: "");if (userInfoListRes.code == 0) {// Get mutual followers list successfullyuserInfoListRes.data?.nextCursor; // The next cursor for paging pulluserInfoListRes.data?.userFullInfoList?.forEach((element) {element?.userID; // User IDelement?.nickName; // User nick nameelement?.faceUrl; // User avatar urlelement?.selfSignature; // User signatureelement?.gender; // User genderelement?.allowType; // User option for allowing others to add friendselement?.customInfo; // User coustom infoelement?.role; // User roleelement?.level; // User levelelement?.birthday; // User birthday});}
nextCursor
parameter of the API with ""
. After a successful callback, if the returned nextCursor
is not ""
, you can input this value to fetch again, until nextCursor
returns ""
, indicating that the fetch is complete.getUserFollowInfo
API to get the count of following/followers/mutual followers for specific users.V2TimValueCallback<List<V2TimFollowInfo>> userFollowInfoListRes = await friendshipManager.getUserFollowInfo(userIDList: ['user1']);if (userFollowInfoListRes.code == 0) {// Obtained successfullyuserFollowInfoListRes.data?.forEach((element) {element?.resultCode; // Result code: 0 indicates success, while any other value indicates failureelement?.resultInfo; // Result informationelement?.userID; // User IDelement?.followingCount; // The count of users this user is followingelement?.followersCount; // The count of followers for this userelement?.mutualFollowersCount; // The count of mutual followers for this user});}
checkFollowType
API to check your following relationship with specified users.followType
of V2TimFollowTypeCheckResul
:V2TimFollowTypeCheckResult.followType | Relationship with yourself |
V2TIM_FOLLOW_TYPE_NONE = 0 | No following relationship |
V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWING_LIST = 1 | The user is only in my following list |
V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWERS_LIST = 2 | The user is only in my followers list |
V2TIM_FOLLOW_TYPE_IN_BOTH_FOLLOWERS_LIST = 3 | Mutually follow with the user (the user is both in my following list and in my followers list) |
V2TimValueCallback<List<V2TimFollowTypeCheckResult>> followTypeCheckRes = await friendshipManager.checkFollowType(userIDList: ['user1']);if (followTypeCheckRes.code == 0) {// Checked the follow relationship successfullyfollowTypeCheckRes.data?.forEach((element) {element?.resultCode; // Result code: 0 indicates success, while any other value indicates failureelement?.resultInfo; // Result informationelement?.userID; // User IDelement?.followType; // Type of following relationship});}
checkFollowType
API is up to 20 calls within 5 seconds, and each call can support up to 100 users.List Change Notification | Description |
Follow List Change Notification onMyFollowingListChanged | When the isAdd in the notification is true , it signifies a notification for adding a user to the list, and at this time, the complete user profile is returnedWhen the isAdd in the notification is false , it signifies a notification for deleting a user from the list, and at this time, only the user ID is included in the returned user profile |
Followers List Change Notification onMyFollowersListChanged | |
Mutual Followers List Change Notification onMutualFollowersListChanged | |
addFriendListener
beforehand to add a relationship event listener.Alice
and Bob
. During the process of mutual following, the related list change notifications and relationship changes are as follows:Event | Alice | Bob | ||
| Notifications received | Relationship with Bob | Notifications received | Relationship with Alice |
Alice follows Bob | ||||
Bob follows Alice | |
Alice
and Bob
, who are mutual followers, during the process of mutually unfollowing, the related list change notifications and relationship changes are as follows:Event | Alice | Bob | ||
| Notifications received | Relationship with Bob | Notifications received | Relationship with Alice |
Alice unfollows Bob | | | ||
Bob unfollows Alice |
V2TimFriendshipListener listener = V2TimFriendshipListener(OnMyFollowingListChanged: (List<V2TimUserFullInfo> userInfoList, bool isAdd) async {if (isAdd) {// Receive notification of users added to following list} else {// Receive notification of users deleted from following list}},OnMyFollowersListChanged: (List<V2TimUserFullInfo> userInfoList, bool isAdd) async {if (isAdd) {// Receive notification of users added to followers list} else {// Receive notification of users deleted from followers list}},OnMutualFollowersListChanged: (List<V2TimUserFullInfo> userInfoList, bool isAdd) async {if (isAdd) {// Receive notification of users added to mutual followers list} else {// Receive notification of users deleted from mutual follow list}}// Other member functions ...);// Add a relationship chain listenerTencentImSDKPlugin.v2TIMManager.getFriendshipManager().addFriendListener(listener: listener);// Remove a relationship chain listenerfriendshipManager.removeFriendListener(listener : friendshipListener);
Was this page helpful?