Seamless Membership Management: Channel membership operations provide reliable joining and leaving functionality with idempotent behavior. Once joined, users can participate in conversations and receive updates, while membership status can be observed in real-time for dynamic UI updates.

Membership Operations

Channel membership management supports both joining and leaving operations with automatic membership tracking and real-time status updates.

Join Channels

Become a channel member
  • Idempotent operation with safe retry behavior
  • Immediate participation in conversations
  • Automatic membership status updates

Leave Channels

Remove membership from channels
  • Clean disconnection from channel activity
  • Stop receiving messages and updates
  • Permanent membership removal

Membership Management

Add user to channel membershipThe joinChannel function allows users to join a channel, making them a member of the channel. This function takes one parameter, channelId which is the ID of the channel that the user wishes to join.Once the user joins the channel, they will be able to participate in conversations and receive updates about the channel’s activity. It is important to note that this function is idempotent, which means that it can be called multiple times without causing any issues. If the user has already joined the channel, a successful result will still be returned.

Parameters

ParameterTypeRequiredDescription
channelIdStringUnique identifier of the channel to join

Code Examples

do {
    let channel = try await channelRepository.joinChannel(channelId: "<channel-id>")
    print("Sucessfully join a channel: \(channel.channelId)")
} catch {
    print("Unable to join a channel: \(error)")
}
Idempotent Operation: This function can be called multiple times safely. If the user has already joined the channel, a successful result will still be returned without any issues.

Channel Membership Concepts

Understanding the relationship between different channel operations is crucial for effective membership management:

Operation Differences

Next Steps

Membership Strategy: Use the idempotent nature of joinChannel to safely retry operations, and always observe membership status for dynamic UI updates, especially to handle banned user scenarios gracefully.