How to use Friends

How to use Friends

Guide details:

This documentation provides an outline of how to set up and use the Friends relationship in CometChat.

Overview

CometChat offers a feature called Friends, which allows users to establish connections and communicate within your application.

To get started, you’ll want to refer to the API documentation provided by CometChat, which can be found here: CometChat Friends.

Friend management will be handled by your application and can only be handled via the API in CometChat. Associating users as friends lets you restrict users from messaging other users who are not their friends, as well as list all friends for a user that is logged in.

Using Friends will allow us to achieve the following requirements:

  1. Filter Conversations and Users for friends only: Use the CometChat SDK Friends Only property to fetch only friends.

  2. Real-time Presence: Users can see the real-time presence status of their friends, indicating whether they are online or offline. This feature enhances the user experience by enabling timely communication and reducing response times.

  3. Privacy Controls: CometChat’s Friends feature enables you to restrict chat functionality solely to your friends. Non-friends are unable to exchange messages with each other.

Configuring Roles for Friends Chat Only

To begin, create distinct roles for your users within your application. Utilize the API to configure the following parameter for each role:

settings.sendMessagesTo: ‘friendsOnly’

This ensures that users can only send messages to individuals listed as friends.

Role-based Account Creation

Upon user registration, dynamically assign roles based on the user. This establishes clear distinctions and permissions within the system.

Create Your Process for Friends

Utilizing CometChat, you can create a comprehensive use case that includes implementing API triggers, designing user interfaces for chat and friend requests, presenting interactive messages, and managing server-side connections. This approach facilitates and streamlines user communication within the application, ensuring efficient and effective interactions.