CometChat Pro Documentation

You'll find comprehensive guides and documentation to help you start working with CometChat as quickly as possible. Let's jump right in!

Key Concepts

Learn the most important concepts of CometChat, so that it's easier to integrate.

CometChat Dashboard

The CometChat Dashboard enables you to create new apps (projects) and manage your existing apps.

📘

How many apps to create?

Ideally, you should create two apps- one for development and one for production. And you should use a single app irrespective of the number of platforms.

Do not create separate apps for every platform; if you do, your users on different platforms will not be able to communicate with each other!

  • For every app, a unique App ID is generated. This App ID will be required when integrating CometChat within your app.
  • Along with the App ID, you will need to create an Auth Key (from the Dashboard) which can be used for user authentication.

Auth & Rest API Keys

You can generate two types of keys from the dashboard.

TypePrivilegesRecommended Use
Auth KeyThe Auth Key can be used to create & login users.In your client side code (during development)
Rest API KeyThe Rest API Key can be used to perform any CometChat operation.In your server side code

Users

A user is anyone who uses CometChat.

UID

  • Each user is uniquely identified using UID.
  • The UID is typically the primary ID of the user from your database.

🚧

UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.

Auth Token

  • A single user can have multiple auth tokens. The auth tokens should be per user per device.
  • It should be generated by API call ideally, via server to server call. The auth token should then be given to CometChat for login.
  • An Auth Token can only be deleted via dashboard or using REST API.

Authentication

To allow a user to use CometChat, the user must log in to CometChat.

CometChat does not handle user management. You must handle user registration and login at your end. Once the user is logged into your app/site, you can log in the user to CometChat programmatically. So the user does not ever directly login to CometChat.

CometChat does not handle friends management. If you want to associate friends with your users, you must handle friends management in your app. Once two users are friends (i.e. they have accepted each other as friends), then you can associate them as friends in CometChat.

Typical Workflow

Your AppYour ServerCometChat
User registers in your appYou store the user information in your database (e.g. ID, name, email, phone, location etc. in users table)You add the user to CometChat (only ID & name) using the Rest API
User logs in to your appYou verify the credentials, login the user and retrieve the user IDYou log in the user to CometChat using the same user ID programmatically
User sends a friend requestYou display the request to the potential friendNo action required
User accepts a friend requestYou display the users as friendsYou add both the users as friends using the Rest API

User Roles

A role is a category for a group of similar users. For example, you may want to group your premium users using the role "Premium". You then use this to filter users or enable/disable features by writing conditional code.

User List

  • The User List can be used to build the Contacts or Who's Online view in your app.
  • The list of users can be different based on the logged-in user.

Groups

A group can be used for multiple users to communicate with each other on a particular topic/interest.

GUID

  • Each group is uniquely identified using GUID.
  • The GUID is typically the primary ID of the group from your database. If you do not store group information in your database, you can generate a random string for use as GUID.

🚧

GUID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.

Types

CometChat supports three different types of groups:

TypeVisibilityParticipation
PublicAll usersAny user can choose to join
PasswordAll usersAny user with a valid password can choose to join
PrivateOnly users part of the groupInvited users will be auto-joined

Members

Once a participant joins a group, they become a member of the group. Members are part of the group indefinitely i.e. they will keep receiving messages, calls & notifications. To stop, the participant must either be kicked, banned or intentionally leave the group.

CometChat supports three different types of member scopes in a group:

MemberDefaultPrivileges
AdminGroup creator is assigned Admin scope Change scope of Group Members to admin, moderator or participant.
Can add members to a group.
Kick & Ban Participants/Moderators/Admins
Send & Receive Messages & Calls
Update group
Delete group
Moderator- Change scope of moderator or participant.
Update group
Kick & Ban Participants
Send & Receive Messages & Calls
ParticipantAny other user is assigned Participant scope* Send & Receive Messages & Calls

Messaging

CometChat supports three types of messages:

TypeDescription
TextBy default, every message is considered as a text message.

Along with the text message, custom metadata can be sent in JSON format. For example, you can send custom metadata to identify the original message the current message is in response to (i.e. to implement reply feature).
MediaAny media message like files, audio & video.

Along with the media message, custom metadata can be sent in JSON format. For example, you can add metadata to send a caption along with the media message.
CustomAny custom message like location coordinates.

Updated about a month ago


Key Concepts


Learn the most important concepts of CometChat, so that it's easier to integrate.

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.