Quick Reference for AI Agents & Developers
- Set delegate:
CometChat.logindelegate = self(conform toCometChatLoginDelegate) - Delegate methods:
onLoginSuccess(user:),onLoginFailed(error:),onLogoutSuccess(),onLogoutFailed(error:) - Related: Authentication · Connection Status · Setup
| Delegate Method | Information |
|---|---|
| onLoginSuccess(user: User) | This method is triggered when the user successfully logs into the CometChat SDK. It returns an Object of the User loggedIn. |
| onLoginFailed(error: CometChatException?) | This method is triggered when the user could not successfully log into the CometChat SDK. It returns an Object of the CometChatException. |
| onLogoutSuccess() | This method is called when the user successfully logs out from the CometChat SDK. It does not return anything. |
| onLogoutFailed(error: CometChatException?) | This method is triggered when the user could not successfully log out of the CometChat SDK. It returns an Object of the CometChatException. |
CometChatLoginDelegate as CometChat.logindelegate = self . Here is the example of CometChatLoginDelegate:
- Swift
- Objective C
Delegate Methods
onLoginSuccess(user: User)
This method is triggered when the user successfully logs into the CometChat SDK. It returns aUser object containing all information about the logged-in user.
Sample Payloads
Sample Payloads
- Request
- Success Response
- Error Response
Trigger:
CometChat.login(UID:authKey:) or CometChat.login(authToken:)| Parameter | Type | Value |
|---|---|---|
| UID | String | "cometchat-uid-1" |
| authKey | String | "AUTH_KEY" |
onLoginFailed(error: CometChatException?)
This method is triggered when the user could not successfully log into the CometChat SDK. It returns aCometChatException object with error details.
Sample Payloads
Sample Payloads
- Request
- Success Response
- Error Response
Trigger:
CometChat.login(UID:authKey:) with invalid credentials| Parameter | Type | Value |
|---|---|---|
| UID | String | "invalid_user" |
| authKey | String | "AUTH_KEY" |
onLogoutSuccess()
This method is called when the user successfully logs out from the CometChat SDK. It does not return any data.Sample Payloads
Sample Payloads
- Request
- Success Response
- Error Response
Trigger:
CometChat.logout()| Parameter | Type | Value |
|---|---|---|
| — | — | No request parameters |
onLogoutFailed(error: CometChatException?)
This method is triggered when the user could not successfully log out of the CometChat SDK. It returns aCometChatException object with error details.
Sample Payloads
Sample Payloads
- Request
- Success Response
- Error Response
Trigger:
CometChat.logout() when no user is logged in| Parameter | Type | Value |
|---|---|---|
| — | — | No request parameters |