Skip to main content
Quick Reference for AI Agents & Developers
  • Set delegate: CometChat.logindelegate = self (conform to CometChatLoginDelegate)
  • Delegate methods: onLoginSuccess(user:), onLoginFailed(error:), onLogoutSuccess(), onLogoutFailed(error:)
  • Related: Authentication · Connection Status · Setup
CometChat SDK provides you with a mechanism to get real-time status whenever a user logs into CometChat or logs out from CometChat. Login Listener provides you with the below 4 methods: In order to use the Delegate methods you must add protocol conformance CometChatLoginDelegate as CometChat.logindelegate = self . Here is the example of CometChatLoginDelegate:

Delegate Methods

onLoginSuccess(user: User)

This method is triggered when the user successfully logs into the CometChat SDK. It returns a User object containing all information about the logged-in user.

onLoginFailed(error: CometChatException?)

This method is triggered when the user could not successfully log into the CometChat SDK. It returns a CometChatException object with error details.

onLogoutSuccess()

This method is called when the user successfully logs out from the CometChat SDK. It does not return any data.

onLogoutFailed(error: CometChatException?)

This method is triggered when the user could not successfully log out of the CometChat SDK. It returns a CometChatException object with error details.