Skip to main content
Allow users to view and manage the list of users they have blocked. This feature is essential for user safety, privacy, and giving users control over their social experience.

Blocked Users List

View all users you have blocked, including their display name, avatar, and user ID.

Privacy & Control

Only users you have blocked are shown. Inactive or deleted users are excluded.
You can only view users you have blocked—not users who have blocked you. Blocked users that are inactive or deleted will not appear in your list.

Product Behavior

  • The blocked users list displays:
    • User ID
    • Display Name
    • Avatar
    • Other relevant user information
  • Only active users you have blocked are shown
  • You cannot see users who have blocked you

Get Blocked Users List (Paginated)

Retrieve and manage your blocked users list with pagination. This returns a live collection that automatically reflects changes when you block or unblock users.

How It Works

  • Live collection — Results are returned as a live collection
  • Paginated — Results are loaded in pages. Use the platform’s pagination mechanism to load additional pages on demand.

Parameters

ParameterTypeRequiredDescription
limitNumberNoNumber of users per page (default varies by platform, typically 20–25)

Usage

// Observe blocked users list
let token = userRepository.getBlockedUsers().observe { liveCollection, _, error in
    // Handle liveCollection (list of blocked users)
    // Handle error if needed
}
When to use this: Use the paginated getBlockedUsers() for building a “Manage Blocked Users” screen where users can browse, scroll through, and unblock people. The live collection keeps the UI in sync automatically. For one-shot use cases like feed filtering, see Get All Blocked Users below.

Get All Blocked Users (Non-Paginated)

Platform Availability: getAllBlockedUsers() is currently available on iOS and Android only. Web (TypeScript) support is under development.
Retrieve the complete list of blocked users as a one-shot async call (not a live collection). This is optimized for use cases like feed filtering where you need the full block list upfront without live reactivity.

How It Works

  • One-shot result — Returns the full blocked users list as a single async response, not a live collection.
  • Built-in caching — The SDK caches the result for 5 minutes. The first call fetches from the server; subsequent calls within the TTL window resolve instantly from the local cache.
  • Cache refresh — After 5 minutes, the next call triggers a fresh server fetch.
  • Local changes — If you block or unblock a user between calls, the local cache is updated immediately. The next getAllBlockedUsers() call reflects the change even without a server fetch.
  • Session-aware — The cache resets on logout. After re-login, the next call fetches fresh data.
Cache behavior: Results are cached for 5 minutes. If the blocked users list appears stale, this is expected — wait for the cache to expire or trigger a new call after 5 minutes. Blocking or unblocking a user locally will update the cached list immediately, but changes made from another device will only appear after the cache refreshes.

Usage

import AmitySDK

let userRepository = AmityUserRepository(client: client)

userRepository.getAllBlockedUsers { result in
    switch result {
    case .success(let blockedUsers):
        print("Blocked users: \(blockedUsers.count)")
        for user in blockedUsers {
            print("- \(user.displayName ?? user.userId)")
        }
    case .failure(let error):
        print("Failed to get blocked users: \(error)")
    }
}

Use Case: Feed Filtering

A common use case is filtering out blocked users’ posts from a feed:
// Get all blocked user IDs for local filtering
userRepository.getAllBlockedUsers { result in
    switch result {
    case .success(let blockedUsers):
        let blockedUserIds = Set(blockedUsers.map { $0.userId })
        // Use blockedUserIds to filter feed content locally
    case .failure(let error):
        // Handle error — do not assume empty block list
        print("Error: \(error)")
    }
}

Limitations

  • Hard limit of 100 users — Returns a maximum of 100 blocked users. If a user has more than 100 blocked users, only the most recent 100 are returned.
  • Not a live collection — The result is a one-shot snapshot. It does not automatically update when block/unblock actions occur. Call the function again to get the latest list.
  • Error propagation — If the server fetch fails (e.g., network error), the error is propagated to the caller. The SDK does not return a stale cached list on failure.
For real-time, paginated block lists (e.g., a “Manage Blocked Users” screen), use the existing getBlockedUsers() live collection API above instead.

Best Practices

  • Provide clear UI for managing blocked users
  • Allow easy unblocking from the list
  • Show avatars and display names for quick identification
  • Use pagination for large block lists
  • Update the list in real-time as users are blocked/unblocked