Membership object
Membership is an object that refers to a single user-channel relationship in a chat.
Properties
The Membership object has the following properties:
1public class Membership : UniqueChatEntity {
2 public string Id { get; protected set; }
3 public string UserId { get; }
4 public string ChannelId { get; }
5 public string LastReadMessageTimeToken { get; }
6 public ChatMembershipData MembershipData { get; private set; }
7}
| Parameter | Description |
|---|---|
IdType: string | Unique identifier for the membership which is a combination of UserId and ChannelId. |
UserIdType: string | The user ID of the user that this membership belongs to. |
ChannelIdType: string | The channel ID of the channel that this membership belongs to. |
LastReadMessageTimeTokenType: string | The string time token of last read message on the membership channel. |
MembershipDataType: ChatMembershipData | Contains all the additional data related to the chat membership, including custom data, status, and type. |
ChatMembershipData
The ChatMembershipData object contains the following properties:
| Parameter | Description |
|---|---|
CustomDataType: Dictionary<string, object> | Any custom properties or metadata associated with the channel-user membership. |
StatusType: string | Current status of the membership. When a user is invited to a channel, the status is set to "pending". When the user joins the channel, the status changes to an active state (empty string by default). |
TypeType: string | Type of the membership. Can be used to categorize or classify different membership relationships. |
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
Events
The Membership object has the following event:
1// Event triggered when user-channel membership is updated
2public event Action<Membership> OnMembershipUpdated;
3// Event triggered when user-channel membership is updated (includes change type)
4public event Action<Membership, ChatEntityChangeType> OnUpdate;
Example
An event that is triggered when user-channel membership is updated by the server.
1
Methods
You can call the following methods on the Membership object.
Click on each method for more details.
GetUnreadMessagesCount()LastReadMessageTimeTokenSetLastReadMessage()SetLastReadMessageTimeToken()StreamUpdates()Update()
Use case
For example, you can use the Membership object methods to:
- Update information on the user-channel relationship and get updates on such changes.
- Decide what is the last message read by a user on a given channel.
- Get information on the total amount of messages unread by a user on a channel.