Skip to main content

Monitoring Channel Status Changes

Clients can set up listeners to receive corresponding notifications when changes occur in ultra group channels, such as type changes, member changes, or channel deletions.

  • The scope of notified users varies depending on channel type and whether users are in private channel member lists.
  • After receiving notifications about channel deletions (disbanding) or private channel member list changes, the IMLib SDK will clean up local data based on the specific changes.

Setting Up Channel Status Change Notifications

  1. After SDK initialization but before successfully connecting to IM, call the [[RCChannelClient sharedChannelManager] setUltraGroupChannelDelegate:delegate] method to add a channel change delegate:

    - (void)setUltraGroupChannelDelegate:(id<RCUltraGroupChannelDelegate>)delegate;
  2. Implement the RCUltraGroupChannelDelegate protocol, including notifications for private channel member changes, channel type changes, and channel disbanding:

    /// Notification for channel type changes
    - (void)ultraGroupChannelTypeDidChanged:(NSArray<RCUltraGroupChannelChangeTypeInfo *> *)infoList;

    /// Notification for channel deletion (disbanding)
    - (void)ultraGroupChannelDidDisbanded:(NSArray<RCUltraGroupChannelDisbandedInfo *> *)infoList;

    /// Notification for private channel user list changes
    - (void)ultraGroupChannelUserDidKicked:(NSArray<RCUltraGroupChannelUserKickedInfo *> *)infoList;

Notification for Channel Type Changes

Ultra group channels are categorized as public or private. Changing the channel type of an ultra group can only be done by calling server APIs from the app server. The IMLib SDK does not provide this interface.

When a channel type changes, the SDK notifies the app through the following method:

Interface Prototype

- (void)ultraGroupChannelTypeDidChanged:(NSArray<RCUltraGroupChannelChangeTypeInfo *> *)infoList;

Parameter Description

  • Parameter Description

    Return ValueTypeDescription
    infoListRCUltraGroupChannelChangeTypeInfoChannel change information
  • Channel Change Type Description

    Enumeration ValueValueDescription
    RCUltraGroupChannelChangeTypePublicToPrivate2Ultra group public channel changed to private channel
    RCUltraGroupChannelChangeTypePrivateToPublic3Ultra group private channel changed to public channel
    RCUltraGroupChannelChangeTypePublicToPrivateUserNotIn6Ultra group public channel changed to private channel, but the current user is not in the private channel
tip
  • Public to Private Channel: All users will receive notifications. However, the notifications differ based on whether users are in the private channel member list:

    • Users in the private channel member list will receive a change type of RCUltraGroupChannelChangeTypePublicToPrivate.
    • Users not in the private channel member list will receive a change type of RCUltraGroupChannelChangeTypePublicToPrivateUserNotIn.

    If needed, the app can pre-add users to the private channel member list before changing a public channel to private.

  • Private to Public Channel: Only users in the private channel member list will receive notifications, with the change type RCUltraGroupChannelChangeTypePrivateToPublic.

Notification for Channel Deletion (Disbanding)

Deleting (disbanding) an ultra group channel can only be done by calling server APIs from the app server. The IMLib SDK does not provide this interface.

When a channel is deleted, the IMLib SDK receives the notification through the following method:

Interface Prototype

- (void)ultraGroupChannelDidDisbanded:(NSArray<RCUltraGroupChannelDisbandedInfo *> *)infoList;

Parameter Description

  • Parameter Description

    Return ValueTypeDescription
    infoListRCUltraGroupChannelDisbandedInfoChannel change information

Notification Scope for Channel Deletion

  • Deleting a Public Channel: All users will receive notifications.
  • Deleting a Private Channel: Only users in the private channel member list will receive notifications.

How IMLib Cleans Up Local Data

After receiving the notification, the IMLib SDK will clean up the local conversation of the deleted user but retain the messages in the local conversation.

Notification for Private Channel Member List Changes

The private channel member list of an ultra group can only be modified through server APIs. The IMLib SDK does not provide this interface.

When the private channel member list changes, the IMLib SDK receives the notification through the following method:

Interface Prototype

- (void)ultraGroupChannelUserDidKicked:(NSArray<RCUltraGroupChannelUserKickedInfo *> *)infoList;

Parameter Description

  • Parameter Description:

    Return ValueTypeDescription
    infoListRCUltraGroupChannelUserKickedInfoChannel change information

Notification Scope for Private Channel Member List Changes

For Private Channels: When a user is removed from the private channel member list, only the removed user is notified. For Public Channels: When a user is removed from the private channel member list, no notification is sent. Note that the private channel member list only takes effect when the public channel is changed to a private channel.

How to Clean Up Local Data

  • Current Logged-in User Removed from Private Channel Member List
    • (SDK < 5.4.0): After receiving the notification, the IMLib SDK will delete the local conversation from the conversation list but retain the messages in the conversation.
    • (SDK ≥ 5.4.0): After receiving the notification, the IMLib SDK will not delete the local conversation from the conversation list. You can decide whether to delete the conversation and its messages.
  • Other Cases: If the removed user is not the currently logged-in user, the IMLib SDK will take no action after receiving the notification.