Retrieve channel information using Live Objects that automatically update when channel properties change. Whether you need a single channel or multiple channels by ID, the SDK provides efficient querying with real-time synchronization.

Channel Retrieval Methods

social.plus Chat SDK offers two methods for retrieving channel information, giving you flexibility based on your specific needs:

Single Channel Retrieval

Get specific channel by ID
  • Returns Live Object with real-time updates
  • Complete channel information and metadata
  • Ideal for channel details and validation

Multiple Channel Query

Query up to 100 channels simultaneously
  • Batch retrieval with Live Collection
  • Automatic filtering of invalid channels
  • Efficient for bulk channel operations

Get a Single Channel

Retrieve detailed channel information The function allows users to retrieve information about a specific channel using the channelId parameter. This function returns a Live Object of the AmityChannel class, which contains information such as the channel’s display name, tags, avatar, and other metadata. This function is useful for a variety of purposes, such as displaying information about a channel to users or retrieving channel details before joining the channel.

Parameters

ParameterTypeRequiredDescription
channelIdStringUnique identifier of the channel to retrieve

Code Examples

var token: AmityNotificationToken?

func getChannel(channelId: String) {
    token = channelRepository.getChannel(channelId).observe { liveObject, error in
        if let error = error {
            print(error)
            return
        }
        guard let channel = liveObject.object else {
            return
        }
        print("Got a channel")
        print("- id: \(channel.channelId)")
        print("- name: \(channel.displayName ?? "no_name")")
    }
}

Get Multiple Channels

Query multiple channels by ID SDK now supports querying channels based on provided channel IDs. The ChannelRepository class includes a getChannels method that takes an array of channel IDs as input and returns a live collection of channels. This live collection will contain all the channels that are being queried in the first page. This live collection will not support pagination. Any update to the channels present in this live collection will be automatically notified to the user. Furthermore:
  • This live collection will only contain valid channels. In case of invalid channels (such as user gets banned etc.) the list may exclude those channels.
  • If any channel id is invalid, live collection will throw error.
The maximum number of channels that can be queried is 100.

Parameters

ParameterTypeRequiredDescription
channelIdsArray<String>Array of channel IDs to retrieve (max 100)

Code Examples

func queryChannelByIds() {
    // List of channel ids to query
    let channelIds = ["channel-1","channel-2","channel-3","channel-4"]
    token = channelRepository.getChannels(channelIds: channelIds).observe({ liveCollection, _, error in
        
        // Access channels with above ids
        let channels = liveCollection.snapshots
    })
}

Limitations

Collection Persistence: If the channel is not public and user leaves the channel, the channel will still remain in the live collection until user refresh or resets the live collection.

Next Steps

Development Tip: Use single channel retrieval for displaying specific channel details and batch retrieval when you need to load multiple channels efficiently. Live Objects provide automatic updates for real-time synchronization.