Logout
Logs the user out by invalidating the session and clearing associated data. This method ensures the user's session is securely terminated.
Steps to Logout
- Call the
logout()
method using an instance ofLMChatClient
. - Pass the
LogoutRequest
object containing the required details. - Handle the response using the completion handler to check for success or errors.
let request = LogoutRequest.builder()
.refreshToken("YOUR_REFRESH_TOKEN")
.deviceId("YOUR_DEVICE_ID")
.build()
LMChatClient.shared.logout(request) { response in
switch response {
case .success:
print("User logged out successfully.")
case .failure(let error):
print("Logout failed: \(error.localizedDescription)")
default:
print("No response received")
}
}
Parameters
LogoutRequest
The LogoutRequest
model encapsulates the necessary details to log the user out.
VARIABLE | TYPE | DESCRIPTION | OPTIONAL |
---|---|---|---|
refreshToken | String? | Refresh token for the user session | ✔️ |
deviceId | String? | Unique identifier for the device | ✔️ |