Key Benefit: Implement role-based access control to manage user permissions and moderation capabilities, ensuring proper channel governance and security.

Feature Overview

Role Management enables you to assign and manage different permission levels within chat channels. Roles define varying levels of access and permissions that can be assigned to users, allowing for structured channel governance and moderation.

Role Assignment

Add roles to members
  • Assign moderator permissions
  • Grant custom role access
  • Promote trusted users
  • Bulk role operations

Role Removal

Remove roles from members
  • Demote moderators
  • Revoke permissions
  • Manage role transitions
  • Maintain role hierarchy
Channel Type Limitation: Role management applies only to Live and Community channels. This feature is not available for Conversation and Broadcast channels.

Role Hierarchy

Understanding the role hierarchy is essential for effective channel governance:
RoleAuthority LevelCapabilities
Channel CreatorHighestAutomatically assigned as moderator, cannot be removed
ModeratorsHighCan promote/demote other users, manage channel activities
Custom RolesVariableApplication-defined permissions
MembersStandardBasic channel participation
Important Rules:
  • The channel creator is automatically assigned as the channel moderator
  • The last moderator cannot leave a community (error will be displayed)
  • Channel moderators can promote users to moderators
  • Channel moderators can demote other moderators to regular members

Implementation Guide

Assign roles to channel membersGrant users specific roles within channels to provide them with appropriate permissions and responsibilities.

Core Operation

MethodPurposeWhen to Use
addRoleAssign role to usersPromoting users to moderators or custom roles

Code Examples

// Add a role to member
do {
let success = try await channelModeration.addRole("<role>", userIds: ["<user-id>"])
} catch {
// Handle error here
}
Best Practice: Always validate user membership before assigning roles. Consider implementing confirmation dialogs for role assignments, especially for moderator promotions.

Best Practices

Implementation Strategy: Start with basic role assignment and removal, then add validation and error handling. Implement role transitions and bulk operations for advanced use cases. Focus on creating clear governance policies alongside the technical implementation.