Use this file to discover all available pages before exploring further.
AI Integration Quick Reference
// Check existing sessionlet user = CometChat.getLoggedInUser()// Login with Auth Key (development only)CometChat.login(UID: "cometchat-uid-1", authKey: "AUTH_KEY", onSuccess: { user in print("Logged in: \(user.stringValue())")}, onError: { error in print("Login failed: \(error.errorDescription)")})// Login with Auth Token (production)CometChat.login(authToken: "AUTH_TOKEN", onSuccess: { user in print("Logged in: \(user.stringValue())")}, onError: { error in print("Login failed: \(error.errorDescription)")})// LogoutCometChat.logout(onSuccess: { _ in print("Logged out")}, onError: { error in print("Logout failed: \(error.errorDescription)")})
Create users via:Dashboard (testing) | REST API (production)
Test UIDs:cometchat-uid-1 through cometchat-uid-5
After initializing the SDK, the next step is to authenticate your user. CometChat provides two login methods — Auth Key for quick development, and Auth Token for production — both accessed through the login() method.
A user must exist in CometChat before they can log in.
During development: Create users from the CometChat Dashboard. Five test users are already available with UIDs cometchat-uid-1 through cometchat-uid-5.
The SDK persists the logged-in user’s session locally. Before calling login(), always check whether a session already exists — this avoids unnecessary login calls and keeps your app responsive.
if let user = CometChat.getLoggedInUser() { // User is already logged in — proceed to your app}
If getLoggedInUser() returns nil, no active session exists and you need to call login().