Follow / Unfollow
Following relationships are a fundamental part of social networks. This creates a relationship between users in Social features.
the connection between users will be used to determine the visibility and the accessibility of data in User Feed and Global feed data.
User relationship concept
In the current state, our SDK provides a one-direction relationship. For example, when user A has followed User B, in this case, the system will know that user A has connected to user B.
User Connection method concept
In the current state, our SDK provides 2 ways for users to create relationships with other users, this connection method will be applied to every user in the network.
1. With request process
Once a user sends the Follow action to the target userId
, the system will send the request to the target user. Until the target user accepts the follow request, the connection will not yet be established.
2. Without Request process
Once a user sends the Follow action to the target userId
, the system will automatically establish the connection between 2 users.
As default, the connection method is With request process.
If you wish to change the connection method, you can contact our support team to choose between these 2 options.
Get follow status and connection counter
The first step to start following other users is to know the connection status of the target user. You can follow this line of code.
The follow feature functionalities are packed in AmityUserRepository
and are able to call through followManager
For myself
The getMyFollowInfo
method will call the followInfo API
.
For other user
The getUserFollowInfo
method will call the userId/followInfo API
.
Our SDK does provide 3 status
1.Accept
: this status means the target user has already connected to the SDK method caller.
2.Pending
: this status mean the target user has already received the follow request from the SDK method caller. This status will only available when the connection method setting is With request process
3.None
: this status mean the target user has not connected to the SDK caller.
With this method , you can also receive the total count of
1.Following counter : this is the total number of users who the target user has follow.
2.Follower counter : this is the total number of users who followed the target user.
3.Pending counter : this is the total number of follow request the target user has received
Follow other user
To follow other users, our SDK has been designed to be easy to use, you can simply pass the userId
who you want to follow and we will do the rest. please try the following code.
Withdraw your follow request or Unfollow other user
In case that you want to withdraw your request. You can follow this code.
Get the list of Followers
To see the Follower user list, you can follow this code.
For myself
For other user
We currently do not support sorting of the follower user list.
Get the list of the Following users
To see the Following user list, you can try this code.
For myself
For other user
We currently do not support sorting of the following user list.
Get the list of the Follower request
To see the Following request list, you can try this code.
We currently do not support sorting of the following request user list.
Accept the follower request
To accept the follower request, you can try this code.
If the Follower request is no longer available (either the follower request sender has withdrawn the request or the request has been accepted or declined before), SDK will return the error message.
Decline the follower request
To decline the follower request, you can try this code.
If the Follower request is no longer available (either the follower request sender has withdrawn the request or the request has been accepted or declined before), SDK will return the error message.
Getting Realtime Updates
By default, when you observe live data on this feature:
The SDK first returns you the local cache, if there is any.
The SDK will then try to fetch the data from server, and notify you with the fresh data.
On your app, you will get the latest snapshot at the time when the SDK fetches the data. However, you won't be able to get any further updates via the same live data instance.
If there is a use-case that you need to get data updates through the life-time of live data, you must subscribe to receive the real-time events.
For this feature, SDK provides you AmityFollowTopic that you can subscribe to get realtime updates.
Below is a sample code that show the implementation of MyFollowerListViewController.
The code demonstrates how to subscribe a real-time event, and observe data updates through the life-time of the page.
Please refer to Realtime Events for more information.
Last updated