Skip to main content
  • User delegate: CometChat.userdelegate = self (conform to CometChatUserDelegate) — onUserOnline(user:), onUserOffline(user:)
  • Group delegate: CometChat.groupdelegate = self (conform to CometChatGroupDelegate) — member joined/left/kicked/banned events
  • Message delegate: CometChat.messagedelegate = self (conform to CometChatMessageDelegate) — message received/edited/deleted/reaction events
  • Call delegate (superseded): CometChat.calldelegate = self (conform to CometChatCallDelegate) — legacy incoming/outgoing call events; new apps use the Calls SDK’s CometChatCalls.addIncomingCallListener (Ringing)
  • Login delegate: CometChat.addLoginListener(_:_:) (conform to CometChatLoginDelegate) — login/logout success/failure events
  • Connection delegate: CometChat.addConnectionListener(_:_:) (conform to CometChatConnectionDelegate) — connection status events
  • AI Assistant delegate: CometChat.addAIAssistantListener(_:_:) (conform to AIAssistantEventsDelegate) — AI events
  • Related: User Presence · Receive Message · Ringing
CometChat provides 4 listeners (Delegates) viz.
  1. User Delegate (Listener)
  2. Group Delegate (Listener)
  3. Message Delegate (Listener)
  4. Call Delegate (Listener)

User Delegate Methods

The CometChat provides you with live events related to users. Below are the callback methods provided by the CometChatUserDelegate. In order to use the Delegate methods you must add protocol conformance CometChatUserDelegate as Shown Below:
Do not forget to set your view controller as a CometChat delegate probably in viewDidLoad() as CometChat.userdelegate = self

Group Delegate Methods

The CometChatGroupDelegate provides you with all the real-time events related to groups. Below are the callback methods provided by the CometChatGroupDelegate. You can receive live events related to groups. In order to receive group events, you must add protocol conformance CometChatGroupDelegate as shown below:
Do not forget to set your view controller as a CometChat delegate probably in viewDidLoad() as CometChat.groupdelegate = self

Message Delegate Methods

The CometChatMessageDelegate provides you with live events related to messages. Below are the callback methods provided by the CometChatMessageDelegate. In order to receive incoming messages, you must add protocol conformance CometChatMessageDelegate as shown below:
Do not forget to set your view controller as a CometChat delegate probably in viewDidLoad() as CometChat.messagedelegate = self

Call Delegate Methods

Superseded. CometChatCallDelegate, CometChat.calldelegate and addCallListener(_:_:) are no longer the way calls announce themselves, and a coming Chat SDK release marks them deprecated together with the Chat SDK’s other calling methods. Calls now ring through the Push Notifications SDK (PushKit and CallKit) and announce themselves on the Calls SDK’s CometChatCalls.addIncomingCallListener (onIncomingCallReceived(call:), onIncomingCallEnded(call:reason:)), whether the call arrived by push to a killed app or while the app was running. The caller’s “answered” event is ParticipantEventListener.onParticipantJoined(participant:) on the prepared session. See Ringing and Migrating from Legacy Ringing. The section below is kept for apps still on the legacy flow.
The CometChatCallDelegate provides you with live events related to calls. Below are the callback methods provided by the CometChatCallDelegate. In order to receive all call events, you must add protocol conformance CometChatCallDelegate as shown below:
Do not forget to set your view controller as a CometChat delegate probably in viewDidLoad() as CometChat.calldelegate = self

Login Delegate Methods

The CometChatLoginDelegate provides you with live events related to login and logout. Below are the callback methods provided by the CometChatLoginDelegate. In order to receive login/logout events, you must add protocol conformance CometChatLoginDelegate as shown below:
To add the login listener:
To remove the login listener:

Connection Delegate Methods

The CometChatConnectionDelegate provides you with live events related to the WebSocket connection status. Below are the callback methods provided by the CometChatConnectionDelegate. In order to receive connection events, you must add protocol conformance CometChatConnectionDelegate as shown below:
To add the connection listener:
To remove the connection listener:

AI Assistant Events Delegate

The AIAssistantEventsDelegate provides you with live events related to AI Assistant features. Below are the callback methods provided by the AIAssistantEventsDelegate. In order to receive AI Assistant events, you must add protocol conformance AIAssistantEventsDelegate as shown below:
To add the AI Assistant listener:
To remove the AI Assistant listener:


Offline listeners

With offline support enabled (SDK 4.2.0 or later), CometChatMessageDelegate also receives onMessagesSynced(_:). It fires after the SDK catches up on reconnect and carries updates to already-cached messages that changed while offline: reactions, edits, deletes and receipts. Messages that arrived while offline still come through the typed callbacks such as onTextMessageReceived. Four more listeners report what the SDK does on the device rather than events from the server. Each is documented with examples on its own page.

Next Steps

User Presence

Monitor user online/offline status

Receive Messages

Handle incoming messages in real time

Connection Status

Monitor the SDK connection state

Login Listeners

Listen for login and logout events