Leave Chatroom
The LikeMinds iOS SDK allows users to leave chatrooms, whether open or secret. This guide outlines the steps to leave either type of chatroom using the SDK.
Steps to Leave an Open Chatroom
- Create an object of the
FollowChatroomRequest
class using its builder pattern. Pass false to the value parameter to indicate leaving the chatroom. - Call the
followChatroom()
function in theLMChatClient
class, passing the constructed request object. - Process the LMResponse<NoData> response to confirm whether the user successfully left the chatroom or handle any errors.
let request = FollowChatroomRequest.builder()
.chatroomId("ENTER_CHATROOM_ID")
.uuid("ENTER_UUID")
.value(false) // Indicating the user wants to leave
.build()
LMChatClient.shared.followChatroom(request: request) { response in
if response?.error == nil {
// Handle success
print("Successfully left the open chatroom.")
} else {
// Handle error
print("Error leaving the open chatroom: \(response?.error?.localizedDescription ?? "Unknown error")")
}
}
Steps to Leave a Secret Chatroom
- Create a
LeaveSecretChatroomRequest
object using its builder pattern. - Call the
leaveSecretChatroom()
function in theLMChatClient
class, passing the constructed request object. - Process the LMResponse<NoData> response to confirm whether the user successfully left the chatroom or handle any errors.
let request = LeaveSecretChatroomRequest.builder()
.chatroomId("ENTER_CHATROOM_ID")
.uuid("ENTER_UUID")
.isSecret(true) // Ensure this is set for secret chatrooms
.build()
LMChatClient.shared.leaveSecretChatroom(request: request) { response in
if response?.error == nil {
// Handle success
print("Successfully left the secret chatroom.")
} else {
// Handle error
print("Error leaving the secret chatroom: \(response?.error?.localizedDescription ?? "Unknown error")")
}
}
Models
LeaveSecretChatroomRequest
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
chatroomId | String | ID of the chatroom to leave | |
isSecret | Bool | Flag to indicate that the chatroom is secret | |
uuid | String | Unique identifier for the user leaving the chatroom |