tencent cloud

Feedback

Android&iOS&Windows&Mac

Last updated: 2024-09-09 20:05:57

    Description

    Following feature allows users to follow other users they are interested in, so they can timely receive the latest news, feeds, or event information of these users. The system can provide personalized content recommendations based on the user's following list.
    Followers feature refers to the state of a user being followed by others. When user A follows user B, A becomes a follower of B. Users can view the count of followers, followers list, or profile of followers on their own profile page.
    Through the features, you can create an active, interconnected user network, promoting the spread of information and the building of the community.
    Note:
    This feature is available only in SDK enhanced edition v7.8 or later.
    This feature is only supported by the premium edition. Please purchase the premium edition to use it.

    Display Effect

    

    API Description

    Follow user

    You can call the followUser API (Android / iOS and macOS / Windows) to follow specified users.
    Sample code:
    Android
    iOS & Mac
    Windows
    List<String> userIDList = Arrays.asList("useridA", "useridB");
    V2TIMManager.getFriendshipManager().followUser(userIDList, new V2TIMValueCallback<List<V2TIMFollowOperationResult>>() {
    @Override
    public void onSuccess(List<V2TIMFollowOperationResult> followOperationResultList) {
    // Follow users successfully
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to follow users
    }
    });
    NSArray *useridList = @[@"useridA", @"useridB"];
    [[V2TIMManager sharedInstance] followUser:userIDList succ:^(NSArray<V2TIMFollowOperationResult *> *resultList) {
    // Follow users succeeded
    } fail:^(int code, NSString *desc) {
    // Failed to follow users
    }];
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMStringVector userIDList;
    userIDList.PushBack(u8"useridA");
    userIDList.PushBack(u8"useridB");
    
    auto callback = new ValueCallback<V2TIMFollowOperationResultVector>{};
    callback->SetCallback(
    [=](const V2TIMFollowOperationResultVector& followOperationResultList) {
    // Follow users successfully
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to follow users
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->FollowUser(userIDList, callback);
    Note:
    This API supports following up to 20 users at a time (excluding yourself, you can follow any other user).
    The maximum number of followers per user is 5000, and there is no limit on the number of fan users.

    Unfollow user

    You can call the unfollowUser API (Android / iOS & Mac / Windows) to unfollow the specified users.
    Sample code:
    Android
    iOS & Mac
    Windows
    List<String> userIDList = Arrays.asList("useridA", "useridB");
    V2TIMManager.getFriendshipManager().unfollowUser(userIDList, new V2TIMValueCallback<List<V2TIMFollowOperationResult>>() {
    @Override
    public void onSuccess(List<V2TIMFollowOperationResult> followOperationResultList) {
    // Unfollow users successfully
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to unfollow users
    }
    });
    NSArray *useridList = @[@"useridA", @"useridB"];
    [[V2TIMManager sharedInstance] unfollowUser:userIDList succ:^(NSArray<V2TIMFollowOperationResult *> *resultList) {
    // Unfollow users successfully
    } fail:^(int code, NSString *desc) {
    // Failed to unfollow users
    }];
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMStringVector userIDList;
    userIDList.PushBack(u8"useridA");
    userIDList.PushBack(u8"useridB");
    
    auto callback = new ValueCallback<V2TIMFollowOperationResultVector>{};
    callback->SetCallback(
    [=](const V2TIMFollowOperationResultVector& followOperationResultList) {
    // Unfollow users successfully
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to unfollow users
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->UnfollowUser(userIDList, callback);
    Note: This API supports unfollowing up to 20 users at a time.

    Get my following list

    You can use the getMyFollowingList API (Android / iOS & Mac / Windows) to pull the list of users you are following.
    Sample code:
    Android
    iOS & Mac
    Windows
    {
    ...
    String nextCursor = "";
    getMyFollowingList(nextCursor);
    ...
    }
    
    public void getMyFollowingList(String nextCursor) {
    V2TIMManager.getFriendshipManager().getMyFollowingList(nextCursor, new V2TIMValueCallback<V2TIMUserInfoResult>() {
    @Override
    public void onSuccess(V2TIMUserInfoResult v2TIMUserInfoResult) {
    StringBuilder stringBuilder = new StringBuilder();
    // Continue with the paged pull
    if (v2TIMUserInfoResult.getNextCursor().length() > 0) {
    // Continue paged pull
    getMyFollowingList(v2TIMUserInfoResult.getNextCursor());
    ...
    } else {
    // Pull complete
    }
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to pull
    }
    });
    }
    - (void)getMyFollowingList:(NSString *)cursor {
    [[V2TIMManager sharedInstance] getMyFollowingList:cursor succ:^(NSString *nextCursor, NSArray<V2TIMUserFullInfo *> *userInfoList) {
    if (nextCursor.length > 0) {
    // Continue with the paged pull
    [self getMyFollowingList:nextCursor];
    //...
    } else {
    // Pull complete
    }
    } fail:^(int code, NSString *desc) {
    // Failed to pull
    }];
    }
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMString nextCursor = u8"";
    
    void GetMyFollowingList(const V2TIMString& nextCursor) {
    auto callback = new ValueCallback<V2TIMUserInfoResult>{};
    callback->SetCallback(
    [=](const V2TIMUserInfoResult& userInfoResult) {
    if (userInfoResult.nextCursor.Length() > 0) {
    // Continue with the paged pull
    GetMyFollowingList(userInfoResult.nextCursor);
    ...
    } else {
    // Pull complete
    }
    
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to pull
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->GetMyFollowingList(nextCursor, callback);
    }
    Note:
    This API returns a maximum of 500 users at a time.
    When pulling the API for the first time, you can enter the nextCursor parameter of the API as "". If the returned nextCursor is not "" after the callback is successful, you can pass this value and pull it again until nextCursor returns "", indicating that the pull is complete.

    Get my followers list

    You can use the getMyFollowersList API (Android / iOS & Mac / Windows) to fetch your own list of follower users.
    Sample code:
    Android
    iOS & Mac
    Windows
    {
    ...
    String nextCursor = "";
    getMyFollowersList(nextCursor);
    ...
    }
    
    public void getMyFollowersList(String nextCursor) {
    V2TIMManager.getFriendshipManager().getMyFollowersList(nextCursor, new V2TIMValueCallback<V2TIMUserInfoResult>() {
    @Override
    public void onSuccess(V2TIMUserInfoResult v2TIMUserInfoResult) {
    StringBuilder stringBuilder = new StringBuilder();
    if (v2TIMUserInfoResult.getNextCursor().length() > 0) {
    // Continue with the paged pull
    getMyFollowersList(v2TIMUserInfoResult.getNextCursor());
    ...
    } else {
    // Pull complete
    }
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to pull
    }
    });
    }
    - (void)getMyFollowersList:(NSString *)cursor {
    [[V2TIMManager sharedInstance] getMyFollowersList:cursor succ:^(NSString *nextCursor, NSArray<V2TIMUserFullInfo *> *userInfoList) {
    if (nextCursor.length > 0) {
    // Continue with the paged pull
    [self getMyFollowersList:nextCursor];
    //...
    } else {
    // Pull complete
    }
    } fail:^(int code, NSString *desc) {
    // Failed to pull
    }];
    }
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMString nextCursor = u8"";
    
    void GetMyFollowersList(const V2TIMString& nextCursor) {
    auto callback = new ValueCallback<V2TIMUserInfoResult>{};
    callback->SetCallback(
    [=](const V2TIMUserInfoResult& userInfoResult) {
    if (userInfoResult.nextCursor.Length() > 0) {
    // Continue with the paged pull
    GetMyFollowersList(userInfoResult.nextCursor);
    ...
    } else {
    // Pull complete
    }
    
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to pull
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->GetMyFollowersList(nextCursor, callback);
    }
    Note:
    This API returns a maximum of 500 users at a time.
    For the first fetch, you can fill the 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.

    Get mutual followers list

    You can call the getMutualFollowersList API (Android / iOS & Mac / Windows) 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).
    Sample code:
    Android
    iOS & Mac
    Windows
    {
    ...
    String nextCursor = "";
    getMutualFollowersList(nextCursor);
    ...
    }
    
    public void getMutualFollowersList(String nextCursor) {
    V2TIMManager.getFriendshipManager().getMutualFollowersList(nextCursor, new V2TIMValueCallback<V2TIMUserInfoResult>() {
    @Override
    public void onSuccess(V2TIMUserInfoResult v2TIMUserInfoResult) {
    StringBuilder stringBuilder = new StringBuilder();
    if (v2TIMUserInfoResult.getNextCursor().length() > 0) {
    // Continue with the paged pull
    getMutualFollowersList(v2TIMUserInfoResult.getNextCursor());
    ...
    } else {
    // Pull complete
    }
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to pull
    }
    });
    }
    - (void)getMutualFollowersList:(NSString *)cursor {
    [[V2TIMManager sharedInstance] getMutualFollowersList:cursor succ:^(NSString *nextCursor, NSArray<V2TIMUserFullInfo *> *userInfoList) {
    if (nextCursor.length > 0) {
    // Continue with the paged pull
    [self getMutualFollowersList:nextCursor];
    //...
    } else {
    // Pull complete
    }
    } fail:^(int code, NSString *desc) {
    // Failed to pull
    }];
    }
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMString nextCursor = u8"";
    
    void GetMutualFollowersList(const V2TIMString& nextCursor) {
    auto callback = new ValueCallback<V2TIMUserInfoResult>{};
    callback->SetCallback(
    [=](const V2TIMUserInfoResult& userInfoResult) {
    if (userInfoResult.nextCursor.Length() > 0) {
    // Continue with the paged pull
    GetMutualFollowersList(userInfoResult.nextCursor);
    ...
    } else {
    // Pull complete
    }
    
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to pull
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->GetMutualFollowersList(nextCursor, callback);
    }
    Note:
    This API returns a maximum of 500 users at a time.
    For the first fetch, you can fill the 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.

    Get the count of following/followers/mutual followers

    You can call the getUserFollowInfo API (Android / iOS & Mac / Windows) to get the count of following/followers/mutual followers for specific users.
    In the successful callback, you can get the count of following, followers, and mutual followers of a specific user from followingCount, followersCount, and mutualFollowersCount of V2TIMFollowInfo (Android / iOS & Mac / Windows) .
    Sample code:
    Android
    iOS & Mac
    Windows
    List<String> userIDList = Arrays.asList("useridA", "useridB");
    V2TIMManager.getFriendshipManager().getUserFollowInfo(userIDList, new V2TIMValueCallback<List<V2TIMFollowInfo>>() {
    @Override
    public void onSuccess(List<V2TIMFollowInfo> followInfoList) {
    // Obtained successfully
    for (V2TIMFollowInfo followInfo : V2TIMFollowInfoList) {
    if (followInfo.getResultCode() == 0) {
    // Here, you can get the count of following/followers/mutual followers corresponding to the user, followInfo.getUserID().
    // That is, followInfo.getFollowingCount(), followInfo.getFollowersCount() and followInfo.getMutualFollowersCount().
    }
    }
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to obtain
    }
    });
    NSArray *useridList = @[@"useridA", @"useridB"];
    [[V2TIMManager sharedInstance] getUserFollowInfo:userIDList succ:^(NSArray<V2TIMFollowInfo *> *resultList) {
    // Obtained successfully
    for (V2TIMFollowInfo *result in resultList) {
    if (result.resultCode == 0) {
    // Here, you can get the count of following/followers/mutual followers corresponding to the user, result.userID.
    // That is, result.followingCount, result.followersCount, and result.mutualFollowersCount.
    }
    }
    } fail:^(int code, NSString *desc) {
    // Failed to obtain
    }];
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMStringVector userIDList;
    userIDList.PushBack(u8"useridA");
    userIDList.PushBack(u8"useridB");
    
    auto callback = new ValueCallback<V2TIMFollowInfoVector>{};
    callback->SetCallback(
    [=](const V2TIMFollowInfoVector& followInfoList) {
    // Obtained successfully
    for (size_t i = 0; i < followInfoList.Size(); ++i) {
    if (followInfoList[i].resultCode == 0) {
    // Here, you can get the count of following/followers/mutual followers for the user, followInfoList[i].userID.
    // That is, followInfoList[i].followingCount, followInfoList[i].followersCount, and followInfoList[i].mutualFollowersCount.
    }
    }
    
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to obtain
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->GetUserFollowInfo(userIDList, callback);

    Check follow type

    You can call the checkFollowType API (Android / iOS & Mac / Windows) to check your following relationship with specified users.
    In the successful callback, you can obtain your relationship with the specified user through the followType of V2TIMFollowTypeCheckResult (Android / iOS & Mac / Windows):
    V2TIMFollowTypeCheckResult.followType
    Relationship with yourself
    
    V2TIM_FOLLOW_TYPE_NONE
    
    No following relationship
    
    V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWING_LIST
    
    The user is only in my following list
    
    V2TIM_FOLLOW_TYPE_IN_MY_FOLLOWERS_LIST
    
    The user is only in my followers list
    
    V2TIM_FOLLOW_TYPE_IN_BOTH_FOLLOWERS_LIST
    
    Mutually follow with the user (the user is both in my following list and in my followers list)
    Sample code:
    Android
    iOS & Mac
    Windows
    List<String> userIDList = Arrays.asList("useridA", "useridB");
    V2TIMManager.getFriendshipManager().checkFollowType(userIDList, new V2TIMValueCallback<List<V2TIMFollowTypeCheckResult>>() {
    @Override
    public void onSuccess(List<V2TIMFollowTypeCheckResult> followTypeCheckResultList) {
    // Successfully checked the follow relationship
    for (V2TIMFollowTypeCheckResult followTypeCheckResult : followTypeCheckResultList) {
    if (followTypeCheckResult.getResultCode() == 0) {
    // Here, you can get the relationship with the user followTypeCheckResult.getUserID(), the follow type followTypeCheckResult.getFollowType()
    }
    }
    }
    
    @Override
    public void onError(int code, String desc) {
    // Failed to check the follow relationship
    }
    });
    NSArray *useridList = @[@"useridA", @"useridB"];
    [[V2TIMManager sharedInstance] checkFollowType:userIDList succ:^(NSArray<V2TIMFollowTypeCheckResultListSucc *> *resultList) {
    // Successfully checked the follow relationship
    for (V2TIMFollowTypeCheckResult *result in resultList) {
    if (result.resultCode == 0) {
    // Here, you can get the relationship with the user result.userID, the follow type result.followType
    }
    }
    } fail:^(int code, NSString *desc) {
    // Failed to check the follow relationship
    }];
    template <class T>
    class ValueCallback final : public V2TIMValueCallback<T> {
    public:
    using SuccessCallback = std::function<void(const T&)>;
    using ErrorCallback = std::function<void(int, const V2TIMString&)>;
    
    ValueCallback() = default;
    ~ValueCallback() override = default;
    
    void SetCallback(SuccessCallback success_callback, ErrorCallback error_callback) {
    success_callback_ = std::move(success_callback);
    error_callback_ = std::move(error_callback);
    }
    
    void OnSuccess(const T& value) override {
    if (success_callback_) {
    success_callback_(value);
    }
    }
    void OnError(int error_code, const V2TIMString& error_message) override {
    if (error_callback_) {
    error_callback_(error_code, error_message);
    }
    }
    
    private:
    SuccessCallback success_callback_;
    ErrorCallback error_callback_;
    };
    
    V2TIMStringVector userIDList;
    userIDList.PushBack(u8"useridA");
    userIDList.PushBack(u8"useridB");
    
    auto callback = new ValueCallback<V2TIMFollowTypeCheckResultVector>{};
    callback->SetCallback(
    [=](const V2TIMFollowTypeCheckResultVector& followTypeCheckResultList) {
    // Successfully checked the follow relationship
    for (size_t i = 0; i < followTypeCheckResultList.Size(); ++i) {
    if (followTypeCheckResultList[i].resultCode == 0) {
    // Here, you can get the relationship with the user followTypeCheckResultList[i].userID, the follow type followTypeCheckResultList[i].followType
    }
    }
    
    delete callback;
    },
    [=](int error_code, const V2TIMString& error_message) {
    // Failed to check the follow relationship
    delete callback;
    });
    
    V2TIMManager::GetInstance()->GetFriendshipManager()->FollowUser(userIDList, callback);
    Note:
    The frequency limit of checkFollowType API is up to 20 calls within 5 seconds, and each call can support up to 100 users.

    Notifications

    The specific list change notifications are as follows:
    List Change Notification
    Description
    Follow List Change Notification
    onMyFollowingListChanged
    (Android / iOS and macOS / Windows)
    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 returned
    When 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
    (Android / iOS and macOS / Windows)
    Mutual Followers List Change Notification
    onMutualFollowersListChanged
    (Android / iOS and macOS / Windows)
    Note:
    To receive notifications for the aforementioned events, please call addFriendListener (Android / iOS and macOS / Windows) beforehand to add a relationship event listener.

    Notifications of adding users to a list

    Suppose there are two users Alice and Bob. During the process of mutual following, the related list change notifications and relationship changes are as follows:

    Notifications of deleting users from a list

    Assuming there are two users, Alice and Bob, who are mutual followers, during the process of mutually unfollowing, the related list change notifications and relationship changes are as follows:
    Sample code:
    Android
    iOS & Mac
    Windows
    V2TIMFriendshipListener v2TIMFriendshipListener = new V2TIMFriendshipListener() {
    @Override
    public void onMyFollowingListChanged(List<V2TIMUserFullInfo> userInfoList, boolean isAdd) {
    if (isAdd) {
    // Receive notification of users added to following list
    } else {
    // Receive notification of users deleted from following list
    }
    }
    
    @Override
    public void onMyFollowersListChanged(List<V2TIMUserFullInfo> userInfoList, boolean isAdd) {
    if (isAdd) {
    // Receive notification of users added to followers list
    } else {
    // Receive notification of users deleted from followers list
    }
    }
    
    @Override
    public void onMutualFollowersListChanged(List<V2TIMUserFullInfo> userInfoList, boolean isAdd) {
    if (isAdd) {
    // Receive notification of users added to mutual followers list
    } else {
    // Receive notification of users deleted from mutual follow list
    }
    }
    };
    
    // Add a relationship chain listener
    V2TIMManager.getFriendshipManager().addFriendListener(v2TIMFriendshipListener);
    // Add a relationship event listener
    [[V2TIMManager sharedInstance] addFriendListener:self];
    
    - (void)onMyFollowingListChanged:(NSArray<V2TIMUserFullInfo *> *)userInfoList isAdd:(BOOL)isAdd {
    if (isAdd) {
    // Receive notification of users added to following list
    } else {
    // User deletion notification from following list
    }
    }
    
    - (void)onMyFollowersListChanged:(NSArray<V2TIMUserFullInfo *> *)userInfoList isAdd:(BOOL)isAdd {
    if (isAdd) {
    // Receive notification of users added to followers list
    } else {
    // Receive notification of users deleted from followers list
    }
    }
    
    - (void)onMutualFollowersListChanged:(NSArray<V2TIMUserFullInfo *> *)userInfoList isAdd:(BOOL)isAdd {
    if (isAdd) {
    // Receive notification of users added to mutual followers list
    } else {
    // Receive notification of users deleted from mutual followers list
    }
    }
    class FriendshipListener final : public V2TIMFriendshipListener {
    public:
    FriendshipListener() = default;
    ~FriendshipListener() override = default;
    
    void OnMyFollowingListChanged(const V2TIMUserFullInfoVector &userInfoList, bool isAdd) override {
    if (isAdd) {
    // Receive notification of users added to following list
    } else {
    // Receive notification of users deleted from following list
    }
    }
    
    void OnMyFollowersListChanged(const V2TIMUserFullInfoVector &userInfoList, bool isAdd) override {
    if (isAdd) {
    // Receive notification of users added to followers list
    } else {
    // Receive notification of users deleted from followers list
    }
    }
    
    void OnMutualFollowersListChanged(const V2TIMUserFullInfoVector &userInfoList, bool isAdd) override {
    if (isAdd) {
    // Receive notification of users added to mutual followers list
    } else {
    // Receive notification of users deleted from mutual followers list
    }
    }
    
    // Other member functions ...
    };
    
    // Add a relationship event listener. Note that the lifespan of the friendshipListener must be maintained before removing the listener to ensure event callbacks are received
    FriendshipListener friendshipListener;
    V2TIMManager::GetInstance()->GetFriendshipManager()->AddFriendListener(&friendshipListener);

    Contact Us

    If you have any questions about this article, feel free to join the Telegram Technical Group, where you will receive reliable technical support.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support