On this page

Join channels

Requires App Context

Enable App Context on your keyset in the Admin Portal to manage memberships.

Use join() to connect a user to a channel and create a membership. The user can receive messages and is recorded as a channel member.

Method signature

join() performs these actions:

  • Subscribes the user to a channel
  • Creates a MembershipImpl object for the user-channel relationship
  • Returns an asynchronous stream that emits new messages on the joined channel

This method takes the following parameters:

1channel.join(
2 custom: [String: JSONCodableScalar]? = nil
3) -> (membership: MembershipImpl, messagesStream: AsyncStream<MessageImpl>)

Input

* required
ParameterDescription
custom
Type: [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

ComponentTypeDescription
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.

1

Last updated on