The Follow/Unfollow User functionality is the core mechanism for establishing and managing relationships between users in your social platform. This feature enables users to connect with others, creating networks that drive content discovery, engagement, and community building.

Instant Connections

Create meaningful connections between users with simple follow/unfollow actions

Request Management

Support both direct following and request-based workflows
You can follow any user by their user ID. The SDK will handle whether the follow is direct or request-based, depending on your network configuration.

Product Behavior

  • If direct following is enabled, the connection is established instantly.
  • If request-based following is enabled, the target user must accept the request before the connection is established.
  • The follow status can be: accepted, pending, none, or blocked.

Follow User

// Follow a user by userId
do {
    let result = try await userRelationship.follow(withUserId: "<user-id>")
    let status = result.1.status
    switch status {
    case .accepted:
        print("follow status: accepted")
    case .pending:
        print("follow status: pending")
    case .none:
        print("follow status: none")
    case .blocked:
        print("follow status: blocked")
    @unknown default:
        print("follow status: unknown")
    }
} catch {
    // Handle error here
}

Unfollow User

Unfollowing a user is immediate and does not require confirmation from the other user. The connection is removed and counters are updated.
// Unfollow a user by userId
do {
    let result = try await userRelationship.unfollow(withUserId: "<user-id>")
} catch {
    // Handle error here
}