AI Integration Quick Reference
AI Integration Quick Reference
- Connect:
CometChat.connect() - Disconnect:
CometChat.disconnect() - Disable auto-connect:
AppSettings.AppSettingsBuilder().autoEstablishSocketConnection(false).build() - Use case: Manual control for battery optimization or specific app flows
- Related: Connection Status · Connection Behaviour · Setup
Default SDK behaviour on login
When the login method of the SDK is called, the SDK performs the below operations:- Logs the user into the SDK
- Saves the details of the logged in user locally.
- Creates a web-socket connection for the logged in user.
Managing the Web-socket connections manually
The CometChat SDK allows you to take control of the web-socket connection. Follow these steps:- While calling the init() function on the app startup, use the
autoEstablishSocketConnection()method provided by theAppSettingsBuilderclass. If set totrue, the SDK manages the web-socket connection internally. If set tofalse, you handle it manually:
- Swift
- Objective C
- You can manage the connection to the web-socket server using the
connect()anddisconnect()methods provided by the SDK. - Connect to the web-socket server
connect() method provided by the CometChat class to establish the connection. Make sure the user is logged in before calling this method (CometChat.getLoggedInUser()). Once connected, you will start receiving all real-time events for the logged in user.
- Swift
- Objective C
- Disconnect from the web-socket server
disconnect() method to break the established connection. Once disconnected, you will stop receiving all real-time events.
- Swift
- Objective C
Next Steps
Connection Status
Monitor the SDK connection state in real time
Connection Behaviour
Understand default WebSocket connection lifecycle
All Real-Time Delegates
Complete reference for all SDK event delegates
Setup SDK
SDK installation and initialization guide