> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-audit-mechanical-fixes.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Call

> Call — CometChat documentation.

## Overview

CometChat's Calls feature is an advanced functionality that allows you to seamlessly integrate one-on-one as well as group audio and video calling capabilities into your application. This document provides a technical overview of these features, as implemented in the Flutter UI Kit.

## Integration

First, make sure that you've correctly integrated the UI Kit library into your project. If you haven't done this yet or are facing difficulties, refer to our [Getting Started](/ui-kit/flutter/v4/getting-started) guide. This guide will walk you through a step-by-step process of integrating our UI Kit into your Flutter project.

Once you've successfully integrated the UI Kit, the next step is to add the CometChat Calls SDK to your project. This is necessary to enable the calling features in the UI Kit. Here's how you do it:

Step 1

### Add Dependency

Add the following dependency to your `pubspec.yaml` file:

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    dependencies:
      cometchat_calls_uikit: ^4.3.6
    ```
  </Tab>
</Tabs>

***

Step 2

### Update build.gradle

If your Flutter project's minimum Android SDK version (minSdkVersion) is below API level 24, you should update it to at least 24. To achieve this, navigate to the `android/app/build.gradle` file and modify the `minSdkVersion` property within the `defaultConfig` section.

<Tabs>
  <Tab title="Groovy">
    ```gradle theme={null}
    defaultConfig {
        minSdkVersion 24
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    ```
  </Tab>
</Tabs>

<Note>
  If you want to use the Flutter UI Kit or enable calling support within it, you'll need to:

  1. Set the `minSdkVersion` to 24 in your `android/app/build.gradle` file.
</Note>

***

Step 3

### Update iOS Podfile

In your Podfile located at `ios/Podfile`, update the minimum iOS version that your project supports to 12.

<Tabs>
  <Tab title="DSL">
    ```
    platform :ios, '12.0'
    ```
  </Tab>
</Tabs>

***

Step 4

### Modify UIKitSettings

To activate the calling features, you'll need to modify the UIKitSettings using `callingExtension` and pass the key in the widget.

Example

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    UIKitSettings uiKitSettings = (UIKitSettingsBuilder()
      ..subscriptionType = CometChatSubscriptionType.allUsers
      ..autoEstablishSocketConnection = true
      ..region = "REGION"//Replace with your App Region
      ..appId = "APP_ID" //Replace with your App ID
      ..authKey = "AUTH_KEY" //Replace with your app Auth Key
      ..extensions = CometChatUIKitChatExtensions.getDefaultExtensions() //Replace this with empty array you want to disable all extensions
      ..callingExtension = CometChatCallingExtension() //Added this to Enable calling feature in the UI Kit
    ).build();

    CometChatUIKit.init(uiKitSettings: uiKitSettings,onSuccess: (successMessage) {
      // TODO("Not yet implemented")
    }, onError: (e) {
      // TODO("Not yet implemented")
    });
    ```
  </Tab>
</Tabs>

To allow launching of Incoming Call screen from any widget whenever a call is received provide set key: CallNavigationContext.navigatorKey in the top most widget of your project (the widget that appears first of your app launch).

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    CometChatUIKit.login(uid, onSuccess: (s) {
      Navigator.push(context, MaterialPageRoute(builder: (context) => CometChatUsersWithMessages(key: CallNavigationContext.navigatorKey)));
    }, onError: (e) {
      // TODO("Not yet implemented")
    });
    ```
  </Tab>
</Tabs>

After adding this dependency, the Flutter UI Kit will automatically detect it and activate the calling features. Now, your application supports both audio and video calling. You will see [CallButtons](/ui-kit/flutter/v4/call-buttons) widget rendered in [MessageHeader](/ui-kit/flutter/v4/message-header) Widget.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/vOzK2L8opJn2Kw6c/images/2258963f-call_overview_cometchat_screens-e9eed2a12770059c6adf29ee05c4e967.png?fit=max&auto=format&n=vOzK2L8opJn2Kw6c&q=85&s=7656b64e9c628fa742283990126e0a4d" alt="Image" width="4498" height="3120" data-path="images/2258963f-call_overview_cometchat_screens-e9eed2a12770059c6adf29ee05c4e967.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/DH2AGzRSUCG5tT9H/images/b4e5c900-call_overview_cometchat_screens-3fe79a578a0e342f5e40ba2c34f30c16.png?fit=max&auto=format&n=DH2AGzRSUCG5tT9H&q=85&s=8437ff5293c3f6fb46fc96a75d0acbdc" alt="Image" width="4498" height="3120" data-path="images/b4e5c900-call_overview_cometchat_screens-3fe79a578a0e342f5e40ba2c34f30c16.png" />
  </Tab>
</Tabs>

### Listeners

For every top-level widget you wish to receive the call events in, you need to register the CallListener listener using the `addCallListener()` method.

<Tabs>
  <Tab title="Dart">
    ```dart theme={null}
    import 'package:cometchat/cometchat_sdk.dart';

    class _YourClassNameState extends State<YourClassName> with CallListener {
      @override
      void initState() {
        super.initState();
        CometChat.addCallListener(listenerId, this); //Add listener
      }

      @override
      void dispose() {
        super.dispose();
        CometChat.removeCallListener(listenerId); //Remove listener
      }

      @override
      void onIncomingCallCancelled(Call call) {
        super.onIncomingCallCancelled(call);
        debugPrint("onIncomingCallCancelled");
      }

      @override
      void onIncomingCallReceived(Call call) {
        super.onIncomingCallReceived(call);
        debugPrint("onIncomingCallReceived");
      }

      @override
      void onOutgoingCallAccepted(Call call) {
        super.onOutgoingCallAccepted(call);
        debugPrint("onOutgoingCallAccepted");
      }

      @override
      void onOutgoingCallRejected(Call call) {
        super.onOutgoingCallRejected(call);
        debugPrint("onOutgoingCallRejected");
      }

      @override
      void onCallEndedMessageReceived(Call call) {
        super.onCallEndedMessageReceived(call);
        debugPrint("onCallEndedMessageReceived");
      }

      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        throw UnimplementedError();
      }
    }
    ```
  </Tab>
</Tabs>

***

## Features

### Incoming Call

The [Incoming Call](/ui-kit/flutter/v4/incoming-call) widget of the CometChat UI Kit provides the functionality that lets users receive real-time audio and video calls in the app.

When a call is made to a user, the Incoming Call widget triggers and displays a call screen. This call screen typically displays the caller information and provides the user with options to either accept or reject the incoming call.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/C9xVaODhNGfTgkE6/images/10cce0d2-call_incoming_cometchat_screens-2534e8e3fd2baa1af3c39992f64a4e0a.png?fit=max&auto=format&n=C9xVaODhNGfTgkE6&q=85&s=49f0b7dec068242e678646fcb4b2ef65" alt="Image" width="4498" height="3120" data-path="images/10cce0d2-call_incoming_cometchat_screens-2534e8e3fd2baa1af3c39992f64a4e0a.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/PArSPrMnmQCdJnO3/images/d575fb83-call_incoming_cometchat_screens-76fcb32bf47b1d60f43a299e4de3a325.png?fit=max&auto=format&n=PArSPrMnmQCdJnO3&q=85&s=930da469f651d01add73a073383e5e4c" alt="Image" width="4498" height="3120" data-path="images/d575fb83-call_incoming_cometchat_screens-76fcb32bf47b1d60f43a299e4de3a325.png" />
  </Tab>
</Tabs>

### Outgoing Call

The [Outgoing Call](/ui-kit/flutter/v4/outgoing-call) widget of the CometChat UI Kit is designed to manage the outgoing call process within your application. When a user initiates an audio or video call to another user or group, this widget displays an outgoing call screen, showcasing information about the recipient and the call status.

Importantly, the Outgoing Call widget is smartly designed to transition automatically into the ongoing call screen once the receiver accepts the call. This ensures a smooth flow from initiating the call to engaging in a conversation, without any additional steps required from the user.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/axXRyft3PU-ANo3t/images/87352b5a-call_outgoing_cometchat_screens-03186778eaf9f91d4de0868f325cd82c.png?fit=max&auto=format&n=axXRyft3PU-ANo3t&q=85&s=83a8462630c8d36829f63737bd63a081" alt="Image" width="4498" height="3120" data-path="images/87352b5a-call_outgoing_cometchat_screens-03186778eaf9f91d4de0868f325cd82c.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/Kgc1yhSJ8H43ZuSx/images/5baad898-call_outgoing_cometchat_screens-554f9430fbdd761d186e1187cbebab1c.png?fit=max&auto=format&n=Kgc1yhSJ8H43ZuSx&q=85&s=8daf45cac97ebeb7b0cc7001d79b9847" alt="Image" width="4498" height="3120" data-path="images/5baad898-call_outgoing_cometchat_screens-554f9430fbdd761d186e1187cbebab1c.png" />
  </Tab>
</Tabs>

### Ongoing Call

The [OngoingCall](/ui-kit/flutter/v4/ongoing-call) widget is the user interface that displays during an ongoing call. For an audio call, this screen displays the participant's name, call duration, and buttons to mute the audio, enable or disable video, switch the camera, and end the call.

For a video call, the Call Screen might additionally display the video footage from both the user's camera and the recipient's camera.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/lGTe4SBrdnJKJDoJ/images/725f11ea-call_ongoing_cometchat_screens-b49b7ab732201b36bd35ccd3759680ff.png?fit=max&auto=format&n=lGTe4SBrdnJKJDoJ&q=85&s=acac6eca3c60d3b52f6fa0de8959aaf1" alt="Image" width="4498" height="3120" data-path="images/725f11ea-call_ongoing_cometchat_screens-b49b7ab732201b36bd35ccd3759680ff.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/GDJ11KCyKQ4fI4Ns/images/a651f3b7-call_ongoing_cometchat_screens-61041cc52588d58ae9974f63e088cfe0.png?fit=max&auto=format&n=GDJ11KCyKQ4fI4Ns&q=85&s=f0f861059bea3778eedb6c242d703d68" alt="Image" width="4498" height="3120" data-path="images/a651f3b7-call_ongoing_cometchat_screens-61041cc52588d58ae9974f63e088cfe0.png" />
  </Tab>
</Tabs>

### Call Logs

[Call Logs](/ui-kit/flutter/v4/call-logs) widget provides you with the records call events such as who called who, the time of the call, and the duration of the call. This information can be fetched from the CometChat server and displayed in a structured format for users to view their past call activities.

<Tabs>
  <Tab title="Android">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/BGGsH7Ab8hL_D05g/images/76b6e0af-call_logs_cometchat_screens-8b85ee71fdec703139a8bafef4357def.png?fit=max&auto=format&n=BGGsH7Ab8hL_D05g&q=85&s=e5f5818f249de9c47f80ede89666c234" alt="Image" width="4498" height="3120" data-path="images/76b6e0af-call_logs_cometchat_screens-8b85ee71fdec703139a8bafef4357def.png" />
  </Tab>

  <Tab title="iOS">
    <img src="https://mintcdn.com/cometchat-22654f5b-docs-audit-mechanical-fixes/tu3JK9T7iskLt8fa/images/4a5a8d2c-call_logs_cometchat_screens-45ac99a4cc24a031c9e71f938d922e97.png?fit=max&auto=format&n=tu3JK9T7iskLt8fa&q=85&s=6c4cd79de2be0d8a0027338400218abe" alt="Image" width="4498" height="3120" data-path="images/4a5a8d2c-call_logs_cometchat_screens-45ac99a4cc24a031c9e71f938d922e97.png" />
  </Tab>
</Tabs>
