Chat / iOS
Chat iOS v4
Chat iOS
Chat
iOS
Home
/
Chat
/
iOS
/
Channel
This is the new Docs for Chat SDK v4 for iOS. To see the previous Docs, click here.

Retrieve a channel by URL

Since a channel URL is a unique identifier of a channel, you can use a URL when retrieving a channel object. We recommend that you store a user's channel URLs to handle the lifecycle or state changes of your app as well as any other unexpected situations. For example, when a user is disconnected from the Sendbird server by temporarily switching to another app, you can provide a smooth restoration of the user's state once the user has returned to your app by using the stored URL to fetch the appropriate channel instance.

Open channel

OpenChannel.getChannel(url: CHANNEL_URL) { channel, error in
    guard error == nil else {
        // Handle error.
        return
    }

    // Through the channel parameter of the callback method,
    // the open channel object identified with CHANNEL_URL is returned by the Sendbird server,
    // and you can get the channel data from the result object.
}

Group channel

GroupChannel.getChannel(url: CHANNEL_URL) { channel, error in
    guard error == nil else {
        // Handle error.
        return
    }

    // Through the channel parameter of the callback method,
    // the group channel object identified with CHANNEL_URL is returned by the Sendbird server,
    // and you can get the group channel's data from the result object.
}