Membership object
Membership
is an object that refers to a single user-channel relationship in a chat.
Properties
The MembershipImpl
class implements the Membership
protocol and takes the following properties:
extension MembershipImpl: Membership {
public var chat: ChatImpl
public var channel: ChannelImpl
public var user: UserImpl
public var custom: [String: JSONCodableScalar]?
public var eTag: String?
public var updated: String?
public var lastReadMessageTimetoken: Timetoken?
...
}
Parameter | Type | Description |
---|---|---|
chat | ChatImpl | Reference to the main Chat protocol. |
channel | ChannelImpl | ChannelImpl object. |
user | UserImpl | UserImpl object. |
custom | [String: JSONCodableScalar] | Any custom properties or metadata associated with the user-channel relationship in the form of a dictionary of key-value pairs. App Context filtering language doesn’t support filtering by custom properties. |
eTag | String | Caching value that changes whenever the MembershipImpl object changes. |
updated | String | Last time the MembershipImpl object was changed. |
lastReadMessageTimetoken | Timetoken | Timetoken of the last message a user read on a given channel. |
API limits
To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs.
Methods
You can call the following methods and properties on the Membership
object.
Click on each method or property for more details.
getUnreadMessagesCount()
lastReadMessageTimetoken
setLastReadMessage()
setLastReadMessageTimetoken()
streamUpdates()
streamUpdatesOn()
update()
Use case
For example, you can use the Membership
-related 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.