Skip to main content

Leave Chatroom

Chatroom exit supports the following scenarios:

  • Passive Exit: Chatrooms have an automatic kick-out mechanism for offline members. When triggered, the RC server will remove users from the chatroom. Banned users will also be removed.
  • Active Exit: The client provides APIs allowing users to voluntarily leave chatrooms.

Passive Exit​

Chatrooms implement an automatic exit mechanism for offline members. When users go offline, the RC server will automatically remove them if the following default conditions are met:

  • If 31 messages are generated within 30 seconds after the user goes offline, triggering automatic removal.
  • If new messages appear in the chatroom after the user has been offline for 30 seconds, triggering automatic removal.
tip
  • Default conditions require new messages in the chatroom to trigger removal. Without message activity, abnormal users cannot be removed.
  • To modify the default message dependency, submit a ticket to enable Real-time Kickout for Abnormal Chatroom Disconnections. Once enabled, the server will use SDK behavior (requiring Android/iOS IMLib SDK ≥ 5.1.6, Web IMLib ≥ 5.3.2) to detect abnormal user states, removing such users within 5 minutes at most.
  • To protect specific users from automatic removal (e.g., for scenarios requiring persistent chatroom presence), use the Server API's Chatroom User Allowlist feature.

Active Exit​

You may choose to actively leave a chatroom.

API Prototype​

- (void)quitChatRoom:(NSString *)targetId
success:(nullable void (^)(void))successBlock
error:(nullable void (^)(RCErrorCode status))errorBlock;

Parameter Description​

ParameterTypeDescription
targetIdNSStringChatroom ID (max 64 characters).
successBlockBlockCallback for successful exit.
errorBlockBlockFailure callback returning RCErrorCode.

Example Code​

[[RCChatRoomClient sharedChatRoomClient] quitChatRoom:self.roomId
success:^{
}error:^(RCErrorCode status) {
}];