Monitoring Channel Status Changes
Clients can set up listeners to receive corresponding notifications when changes occur in ultra group channels, including type changes (applicable only to private channels), member changes, or channel deletions.
- The notification scope varies depending on channel type and whether users are included in private channel member lists.
- Upon receiving notifications for channel deletion (disbanding) or private channel member list changes, the client SDK will clean up local data based on the specific changes.
Setting Up Channel Status Change Notifications
-
After SDK initialization but before successfully connecting to IM, call the
io.rong.imlib.ChannelClient#setUltraGroupChannelListenermethod to add channel change listeners:ChannelClient.getInstance().setUltraGroupChannelListener(); -
Implement the
IRongCoreListener.UltraGroupChannelListenerinterface, which includes notifications for private channel member changes, channel type changes, and channel disbanding./** Notification when users are removed from private channel member lists. Only users within private channel member lists will receive this event. Not triggered for public channels. */
void ultraGroupChannelUserDidKicked(List<UltraGroupChannelUserKickedInfo> infoList);
/** Callback when channel properties change. When changing from private to public, users in the private channel member list receive this event. When changing from public to private, all members receive this event. */
void ultraGroupChannelTypeDidChanged(List<UltraGroupChannelChangeTypeInfo> infoList);
/** Channel disbanding notification. For public channels, all channel members receive deletion notifications. For private channels, only users in the private channel member list receive notifications. */
void ultraGroupChannelDidDisbanded(List<UltraGroupChannelDisbandedInfo> infoList);
Channel Type Change Notifications
Ultra group channels are categorized into public and private channels. Channel type changes can only be implemented by calling server APIs from the App server. The client SDK does not provide interfaces for this.
When channel types change, the SDK notifies the App through the following method:
Interface
void ultraGroupChannelTypeDidChanged(List<UltraGroupChannelChangeTypeInfo> infoList);
Parameter Description
-
Parameter Description
Return Value Type Description infoList UltraGroupChannelChangeTypeInfo Channel change information -
Channel Change Type Description
Enum Value Description ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PUBLIC_TO_PRIVATE Ultra group public channel changed to private channel ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PRIVATE_TO_PUBLIC Ultra group private channel changed to public channel ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PUBLIC_TO_PRIVATE_USER_NOT_IN Ultra group public channel changed to private channel, but the current user is not in the private channel
-
Public to Private Channel: All users receive notifications. However, the notification content varies based on whether users are in the private channel member list:
- Users in the private channel member list receive the change type
ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PUBLIC_TO_PRIVATE. - Users not in the private channel member list receive the change type
ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PUBLIC_TO_PRIVATE_USER_NOT_IN.
If needed, the App can pre-add users to the private channel member list before changing a public channel to private.
- Users in the private channel member list receive the change type
-
Private to Public Channel: Only users in the private channel member list receive notifications, with the change type
ULTRA_GROUP_CHANNEL_CHANGE_TYPE_PRIVATE_TO_PUBLIC.
Channel Deletion (Disbanding) Notifications
Ultra group channel deletion (disbanding) can only be implemented by calling server APIs from the App server. The client SDK does not provide interfaces for this.
When a channel is deleted, the SDK notifies the App through the following method:
Interface
void ultraGroupChannelDidDisbanded(List<UltraGroupChannelDisbandedInfo> infoList);
Parameter Description
-
Parameter Description
Return Value Type Description infoList UltraGroupChannelDisbandedInfo Channel change information
Notification Scope for Channel Deletion
- Public Channel Deletion Notifications: All users receive notifications.
- Private Channel Deletion Notifications: Only users in the private channel member list receive notifications.
Local Data Cleanup
The IMLib SDK cleans up local conversations for deleted users upon receiving notifications but retains messages within those conversations.
Private Channel Member List Change Notifications
Ultra group private channel member lists can only be modified through server APIs. The client SDK does not provide interfaces for this.
When private channel member lists change, the SDK notifies the App through the following method:
Interface
void ultraGroupChannelUserDidKicked(List<UltraGroupChannelUserKickedInfo> infoList);
Parameter Description
-
Parameter Description:
Return Value Type Description infoList UltraGroupChannelUserKickedInfo Channel change information
Notification Scope for Private Channel Member List Changes
- For private channels: Only the removed user receives notifications when removed from the private channel member list.
- For public channels: No notifications are sent when users are removed from the private channel member list. Note: This list only takes effect when the public channel changes to a private channel.
Local Data Cleanup
- Current Logged-in User Removed from Private Channel Member List
- (SDK < 5.4.0): The client SDK removes the local conversation from the conversation list upon receiving the notification but retains the conversation messages.
- (SDK ≥ 5.4.0): The client SDK does not remove the local conversation from the conversation list upon receiving the notification. The App can decide whether to delete the conversation and its messages.
- Other Cases: If the removed user is not the currently logged-in user, the client SDK takes no action upon receiving the notification.