Send and receive targeted messages in groups
Overview
Targeted messages refer to messages sent in a group that are only visible or invisible to certain members.
The logic for determining whether group members can see targeted messages is as follows:
User Role | Is message visible to specified user list | Is user in specified user list | Visible |
---|---|---|---|
Sender | - | Sender cannot be included in the specified user list. | ✔ |
Non-sender | ✔ | ✔ | ✔ |
Non-sender | ✔ | ✘ | ✘ |
Non-sender | ✘ | ✔ | ✘ |
Non-sender | ✘ | ✘ | ✔ |
Targeted messages do not count toward unread counts and do not support operations such as reply, reaction, receipt, and edit.
Send targeted messages
When sending a group message through the server interface Send a group messages, you can configure a user list (ReceiverUserIds) by passing in the TargetOption object, and set Inclusive
to true
or false
to specify whether the message is visible to these users.
Receive targeted messages
After successfully logging in to ZIM SDK, when the user receives a group targeted message that is visible to them, the groupMessageReceived callback is triggered. The isGroupTargetedMessage
value in the received ZIMMessage is true
.
For the example of the groupMessageReceived callback, please refer to Send and receive messages - Receive messages.