Join channels
Requires App Context
To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.
join() connects a user to a given channel and sets membership - this way, the chat user can both watch the channel's content and be its full-fledged member.
Method signature
join() returns an asynchronous stream which produces a new event whenever the current user receives a new message in the channel they have just joined. The method subscribes the user to the channel and establishes a user-channel membership by creating a new MembershipImpl object. The asynchronous stream serves as a message event listener, enabling real-time processing of incoming messages.
This method takes the following parameters:
1channel.join(
2 custom: [String: JSONCodableScalar]? = nil
3) -> (membership: MembershipImpl, messagesStream: AsyncStream<MessageImpl>)
Input
| Parameter | Description |
|---|---|
customType: [String: JSONCodableScalar]Default: n/a | Any custom properties or metadata associated with the channel-user membership in the form of a JSON. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn’t support filtering by custom properties. |
Output
| Component | Type | Description |
|---|---|---|
membership | MembershipImpl | Returned object containing info on the newly created user-channel membership. |
messagesStream | AsyncStream<MessageImpl> | An asynchronous stream that produces a new value every time a new message is published on the current channel. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Join the support channel and mark this membership as premium to add information about your support plan.
1
Other usage
Join the support channel and listen to new messages.
- AsyncStream
- Closure
1
1