AI Integration Quick Reference
AI Integration Quick Reference
- MessageListener
- UserListener
- GroupListener
- CallListener
- ConnectionListener
- LoginListener
- AIAssistantListener
Message Listener
TheMessageListener class provides you with live events related to messages. Below are the callback methods provided by the MessageListener class.
MessageListener Events
To add the
MessageListener, you need to use the addMessageListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the activity/fragment where the MessageListener is declared is not in use, you need to remove the listener using the removeMessageListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.
- Dart
User Listener
TheUserListener class provides you with live events related to users. Below are the callback methods provided by the UserListener class.
UserListener Events
To add the
UserListener, you need to use the addUserListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the activity/fragment where the UserListener is declared is not in use, you need to remove the listener using the removeUserListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.
- Dart
Group Listener
TheGroupListener class provides you with all the real-time events related to groups. Below are the callback methods provided by the GroupListener class.
GroupListener Events
To add the
GroupListener, you need to use the addGroupListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the activity/fragment where the GroupListener is declared is not in use, you need to remove the listener using the removeGroupListener() method which takes the id of the listener to be removed as the parameter. We suggest you call this method in the onPause() method of the activity/fragment.
- Dart
Call Listener
TheCallListener class provides you with real-time events related to calls. Below are the callback methods provided by the CallListener class.
CallListener Events
To add the
CallListener, you need to use the addCallListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the CallListener is no longer needed, remove it using the removeCallListener() method.
- Dart
Connection Listener
TheConnectionListener class provides you with real-time events related to the WebSocket connection status. Below are the callback methods provided by the ConnectionListener class.
ConnectionListener Events
To add the
ConnectionListener, you need to use the addConnectionListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the ConnectionListener is no longer needed, remove it using the removeConnectionListener() method.
- Dart
Login Listener
TheLoginListener class provides you with real-time events related to user authentication. Below are the callback methods provided by the LoginListener class.
LoginListener Events
To add the
LoginListener, you need to use the addLoginListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the LoginListener is no longer needed, remove it using the removeLoginListener() method.
- Dart
AI Assistant Listener
TheAIAssistantListener class provides you with real-time events related to AI assistant interactions. Below are the callback methods provided by the AIAssistantListener class.
AIAssistantListener Events
To add the
AIAssistantListener, you need to use the addAIAssistantListener() method provided by the CometChat class.
- Dart
UNIQUE_LISTENER_ID is the unique identifier for the listener. Please make sure that no two listeners are added with the same listener id as this could lead to unexpected behavior resulting in loss of events.
Once the AIAssistantListener is no longer needed, remove it using the removeAIAssistantListener() method.
- Dart
Next Steps
Receive Messages
Handle incoming messages in real-time using message listeners
User Presence
Track when users come online or go offline
Typing Indicators
Show real-time typing status in conversations
Delivery & Read Receipts
Track message delivery and read status
Connection Status
Monitor SDK connection to CometChat servers
Login Listeners
Monitor user login and logout events