logo
In-app Chat
SDK Error Codes
Powered Byspreading
On this page

Receive tip messages


Overview

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.

Note

Only ZIM SDK 2.15.0 or later supports tip messages.

Procedure

1. Enable the feature

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:

    Note

    The group profile change event is a collection of the following events that need to be specified separately.

    • Group name change
    • Group avatar change
    • Group notice change
    • Group muting status change
  • Group member information change, including the following sub-events:

    Note

    The group member information change event is a collection of the following events that need to be specified separately.

    • Group ownership change
    • Group member role change
    • Group role muting status change

2. Receive a tip message

Listen for the receiveGroupMessage callback to receive the tip message when a group event occurs.

If the group event (ZIMTipsMessageEvent) is a group profile change (ZIMTipsMessageEvent.GROUP_INFO_CHANGED) or group member information change (ZIMTipsMessageEvent.GROUP_MEMBER_INFO_CHANGED), do the following:

  1. Change the changeInfo in the tip message to ZIMTipsMessageGroupChangeInfo or ZIMTipsMessageGroupMemberChangeInfo.
  2. Based on the 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

(ZIMTipsMessageEvent)

EnumerationValue

Read from

ZIMTipsMessageGroupChangeInfo

Group creationGROUP_CREATED1Not required
Group disbandmentGROUP_DISMISSED2
User joinedGROUP_JOINED3
User joined by invitationGROUP_INVITED4
Member leaveGROUP_LEFT5
Member removalGROUP_KICKED_OUT6
Group profile changeGROUP_INFO_CHANGED7Required

Extra information

(ZIMTipsMessageChangeInfoType)

EnumerationValue

Read from

ZIMTipsMessageGroupChangeInfo

Change of multiple items of the group name, group avatar, and group noticeGROUP_DATA_CHANGED1Perform a bitwise operation based on the groupDataFlag to calculate multiple items of the group name, group notice, and group avatar.
Group notice changeGROUP_NOTICE_CHANGED2Read the groupNotice field from ZIMTipsMessageGroupChangeInfo.
Group name changeGROUP_NAME_CHANGED3Read the groupName field from ZIMTipsMessageGroupChangeInfo.
Group avatar changeGROUP_AVATAR_URL_CHANGED4Read the groupAvatarUrl field from ZIMTipsMessageGroupChangeInfo.
Group muting status changeGROUP_MUTE_CHANGED5Read the groupMutedInfo field from ZIMTipsMessageGroupChangeInfo.
Group member information changeGROUP_MEMBER_INFO_CHANGED8Depends on the extra information.

Extra information (ZIMTipsChangeInfoType)

Enumeration Value

Read from

ZIMTipsMessageGroupMemberChangeInfo

Group ownership changeGROUP_OWNER_TRANSFERRED10Not required
Group member role changeGROUP_MEMBER_ROLE_CHANGED11Read the memberRole field from ZIMTipsMessageGroupMemberChangeInfo.
Group role muting status changeGROUP_MEMBER_MUTE_CHANGED12Read the muteExpiredTime field from ZIMTipsMessageGroupMemberChangeInfo.
Untitled
// Receive a group message.
- (void)receiveGroupMessage:(ZIM *)zim 
                 messageList:(NSArray<ZIMMessage *> *)messageList 
                  fromGroupID:(NSString *)fromGroupID {
    
    for (ZIMMessage *message in messageList) {
        // It is a tip message.
        if (message.type == ZIMMessageTypeTips) {
            ZIMTipsMessage *tipsMessage = (ZIMTipsMessage *)message;
            // It is a group profile change event.
            if (tipsMessage.event == ZIMTipsMessageEventGroupInfoChanged) {
                ZIMTipsMessageGroupChangeInfo *info = (ZIMTipsMessageGroupChangeInfo *)tipsMessage.changeInfo;
                
                if (info.type == ZIMTipsMessageChangeInfoTypeGroupDataChanged) {
                    if (info.groupDataFlag & ZIMGroupDataFlagName) {
                        // Group name change.
                        NSString *newGroupName = info.groupName;
                    }
                    
                    if (info.groupDataFlag & ZIMGroupDataFlagNotice) {
                        // Group notice change.
                        NSString *newGroupNotice = info.groupNotice;
                    }
                    
                    if (info.groupDataFlag & ZIMGroupDataFlagAvatarUrl) {
                        // Group avatar change.
                        NSString *newGroupAvatarUrl = info.groupAvatarUrl;
                    }
                }
                
                // The business logic.
            } else if (tipsMessage.event == ZIMTipsMessageEventGroupMemberInfoChanged) {
                // It is a group member information change event.
                ZIMTipsMessageGroupMemberChangeInfo *info = (ZIMTipsMessageGroupMemberChangeInfo *)tipsMessage.changeInfo;
                
                // The business logic.
            }
            
            // Other business logic.
        }
    }
}
1
Copied!

3. Display a tip message

Based on the obtained tip message, generate the corresponding event string and display the event string on the UI.

Previous

Export and import messages

Next

Geofencing