The ZIM SDK converts some user operations on a group (such as group creation and disbandment) into tip messages, A tip message is a special type of message, whose enumeration value is 32
. Tip messages can be generated only by the ZIM backend or ZIM SDK. Users cannot insert tip messages into local conversations, set the read receipt or response for them, or directly delete them. However, users can delete a tip message by deleting all messages in a conversation.
Only ZIM SDK 2.15.0 or later supports tip messages.
Before you implement the receive tip messages
feature, make sure that the following conditions are met:
To enable the tip message feature for the following events, contact ZEGOCLOUD technical support .
Group creation
Group disbandment
User joined
User joined by invitation
Member leave
Member removal
Group profile change, including the following sub-events:
The group profile change event is a collection of the following events that need to be specified separately.
Group member information change, including the following sub-events:
The group member information change event is a collection of the following events that need to be specified separately.
When relevant events occur in a group conversation, you can receive Tips messages by listening for the receiveGroupMessage callback.
If the group event (ZIMTipsMessageEvent) is a group profile change (ZIMTipsMessageEventGroupInfoChanged
) or group member information change (ZIMTipsMessageEventGroupMemberInfoChanged
), do the following:
changeInfo
in the tip message to ZIMTipsMessageGroupChangeInfo or ZIMTipsMessageGroupMemberChangeInfo.type
in the changeInfo
, obtain the event type (ZIMTipsMessageChangeInfoType) and determine the field to be read from the changeInfo
. The ZIM SDK does not assign values to irrelevant fields. For more information, see the sample code at the end of this topic.The following table describes the relationship between the ZIMTipsMessageEvent and the ZIMTipsMessageChangeInfoType.
Event
( |
Enumeration | Value | Read from
|
---|---|---|---|
Group creation |
GroupCreated |
1 |
Not required |
Group disbandment |
GroupDismissed |
2 |
|
User joined |
GroupJoined |
3 |
|
User joined by invitation |
GroupInvited |
4 |
|
Member leave |
GroupLeft |
5 |
|
Member removal |
GroupKickedOut |
6 |
|
Group profile change |
GroupInfoChanged |
7 |
Required |
Extra information
( |
Enumeration | Value | Read from
|
Change of multiple items of the group name, group avatar, and group notice |
GroupDataChanged |
1 |
Perform a bitwise operation based on the groupDataFlag to calculate multiple items of the group name, group notice, and group avatar. |
Group notice change |
GroupNoticeChanged |
2 |
Read the groupNotice field from ZIMTipsMessageGroupChangeInfo . |
Group name change |
GroupNameChanged |
3 |
Read the groupAvatarUrl field from ZIMTipsMessageGroupChangeInfo . |
Group avatar change |
GroupAvatarUrlChanged |
4 |
Read the groupName field from ZIMTipsMessageGroupChangeInfo . |
Group muting status change |
GroupMuteChanged |
5 |
Read the groupMutedInfo field from ZIMTipsMessageGroupChangeInfo . |
Group member information change |
GroupMemberInfoChanged |
8 |
Depends on the extra information. |
Extra information
( |
Enumeration | Value | Read from
|
Group ownership change |
GroupOwnerTransferred |
10 |
Not required |
Group member role change |
GroupMemberRoleChanged |
11 |
Read the memberRole field from ZIMTipsMessageGroupMemberChangeInfo . |
Group role muting status change |
GroupMemberMuteChanged |
12 |
Read the muteExpiredTime field from ZIMTipsMessageGroupMemberChangeInfo . |
// Receive a group message.
zim.on('receiveGroupMessage', (zim, { messageList, fromConversationID }) => {
messageList.forEach((message) => {
// It is a tip message.
if (message.type == 32) {
// It is a group profile change event.
if (message.event == 7) {
const info = message.changeInfo;
// Server API modifies multiple attributes of group data.
if (info.type == 1 && info.groupDataFlag) {
if (info.groupDataFlag & 1 == 1) {
// Group name change.
const groupName = info.groupName;
}
if (info.groupDataFlag & 2 == 2) {
// Group notice change.
const groupNotice = info.groupNotice;
}
if (info.groupDataFlag & 4 == 4) {
// Group avatar change.
const groupAvatarUrl = info.groupAvatarUrl;
}
}
// The business logic.
} else if (message.event == 8) {
// It is a group member information change event.
const info = message.changeInfo;
// The business logic.
}
}
});
});
Based on the obtained tip message, generate the corresponding event string and display the event string on the UI.