> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Outgoing Call

## Overview

The `Outgoing Call` [Component](/ui-kit/ios/v4/components-overview#components) is a visual representation of a user-initiated call, whether it's a voice or video call. It serves as an interface for managing outgoing calls, providing users with essential options to control the call experience. This component typically includes information about the call recipient, call controls for canceling the call, and feedback on the call status, such as indicating when the call is in progress.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/en-qdWUpyc0gQJjA/images/646fb7d7-Outgoing_call_overview_screens-449f93e4b48516a7023538774b586228.png?fit=max&auto=format&n=en-qdWUpyc0gQJjA&q=85&s=4feb7a9876c70d077dce2c47f792116e" width="2653" height="3120" data-path="images/646fb7d7-Outgoing_call_overview_screens-449f93e4b48516a7023538774b586228.png" />
</Frame>

***

***

## Usage

### Integration

`CometChatOutgoingCall` being a custom **view controller**, offers versatility in its integration. It can be seamlessly launched via button clicks or any user-triggered action, enhancing the overall user experience and facilitating smoother interactions within the application.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatOutgoingCall = CometChatOutgoingCall()
    cometChatOutgoingCall.set(call: call)

    cometChatOutgoingCall.modalPresentationStyle = .fullScreen
    self.present(cometChatOutgoingCall, animated: true)
    ```
  </Tab>
</Tabs>

<Note>
  If you are already using a navigation controller, you can use the `pushViewController` function instead of presenting the view controller.
</Note>

### Actions

[Actions](/ui-kit/ios/v4/components-overview#actions) dictate how a component functions. They are divided into two types: Predefined and User-defined. You can override either type, allowing you to tailor the behavior of the component to fit your specific needs.

##### 1. SetOnCancelClick

The `setOnCancelClick` action is typically triggered when the call is ended, carrying out default actions. However, with the following code snippet, you can effortlessly customize or override this default behavior to meet your specific needs.

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let cometChatOutgoingCall = CometChatOutgoingCall()
      .setOnCancelClick { call, controller in
      //Perform Your Action

    }
    ```
  </Tab>
</Tabs>

***

### Filters

**Filters** allow you to customize the data displayed in a list within a Component. You can filter the list based on your specific criteria, allowing for a more customized. Filters can be applied using RequestBuilders of Chat SDK.

The OutgoingCall component does not have any exposed filters.

***

### Events

[Events](/ui-kit/ios/v4/components-overview#events) are emitted by a `Component`. By using event you can extend existing functionality. Being global events, they can be applied in Multiple Locations and are capable of being Added or Removed.

Events emitted by the Outgoing call component is as follows.

| Event                      | Description                                  |
| -------------------------- | -------------------------------------------- |
| **onOutgoingCallAccepted** | Triggers when the outgoing call is accepted. |
| **onOutgoingCallRejected** | Triggers when the outgoing call is rejected. |

<Tabs>
  <Tab title="Add Listener">
    ```swift theme={null}
    // View controller from your project where you want to listen events.
    public class ViewController: UIViewController {

       public override func viewDidLoad() {
            super.viewDidLoad()

           // Subscribing for the listener to listen events from user module
            CometChatCallEvents.addListener("UNIQUE_ID", self as CometChatCallEventListener)
        }

    }
     // Listener events from user module
    extension  ViewController: CometChatCallEventListener {

        func onOutgoingCallAccepted(call: Call) {
            // Do Stuff
        }

        func onOutgoingCallRejected(call: Call){
            // Do Stuff
        }
    }
    ```

    ```swift Emitting Group Events theme={null}
    //emit this when the other user accepts the call
    CometChatCallEvents.emitOnOutgoingCallAccepted(call: Call)

    //emit this when the other user rejects a call
    CometChatCallEvents.emitOnOutgoingCallRejected(call: Call)
    ```
  </Tab>
</Tabs>

***

<Tabs>
  <Tab title="Remove Listener">
    ```swift View controller theme={null}
    public override func viewWillDisappear(_ animated: Bool) {
          // Uncubscribing for the listener to listen events from user module
          CometChatCallEvents.removeListener("LISTENER_ID_USED_FOR_ADDING_THIS_LISTENER")
    }
    ```
  </Tab>
</Tabs>

***

## Customization

To fit your app's design requirements, you can customize the appearance of the conversation component. We provide exposed methods that allow you to modify the experience and behavior according to your specific needs.

### Style

Using Style you can customize the look and feel of the component in your app, These parameters typically control elements such as the color, size, shape, and fonts used within the component.

##### 1. OutgoingCall Style

You can customize the appearance of the `OutgoingCall` Component by applying the `OutgoingCallStyle` to it using the following code snippet.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/wmExTb2jx2mL9tyJ/images/ad3f411a-Outgoing_call_style_screens-d36a15a68574ec7b4959830f27270f87.png?fit=max&auto=format&n=wmExTb2jx2mL9tyJ&q=85&s=6d38792a629effdc68fb47f300d35308" width="4948" height="3120" data-path="images/ad3f411a-Outgoing_call_style_screens-d36a15a68574ec7b4959830f27270f87.png" />
</Frame>

<Tabs>
  <Tab title="Swift">
    ```swift theme={null}
    let outgoingcall = OutgoingCallStyle()
    .set(subtitleColor: .black)
    .set(titleColor: .orange)
    .set(background: .cyan)
    .set(cornerRadius: CometChatCornerStyle.init(cornerRadius: 8))

    let cometChatOutgoingCall = CometChatOutgoingCall()
    .set(outgoingCallStyle: outgoingCallStyle)
    ```
  </Tab>
</Tabs>

List of properties exposed by OutgoingCallStyle

| Property              | Description               | Code                                       |
| --------------------- | ------------------------- | ------------------------------------------ |
| **set Background**    | Sets the background color | `.set(background: UIColor)`                |
| **set CornerRadius**  | Sets the corner radius    | `.set(cornerRadius: CometChatCornerStyle)` |
| **set BorderWidth**   | Sets the border width     | `.set(borderWidth: CGFloat)`               |
| **set BorderColor**   | Sets the border color     | `.set(borderColor: UIColor)`               |
| **set TitleColor**    | Sets the title color      | `.set(titleColor: UIColor)`                |
| **set TitleFont**     | Sets the title font       | `.set(titleFont: UIFont)`                  |
| **set SubtitleColor** | Sets the subtitle color   | `.set(subtitleColor: UIColor)`             |
| **set SubtitleFont**  | Sets the subtitle font    | `.set(subtitleFont: UIFont)`               |

##### 2. Avatar Styles

To apply customized styles to the `Avatar` component in the OutgoingCall Component, you can use the following code snippet. For further insights on `Avatar` Styles [refer](/ui-kit/ios/v4/avatar#avatarstyle)

<Tabs>
  <Tab title="Swift">
    ```swift Swift theme={null}
    // Creating  AvatarStyle object
    let avatarStyle = AvatarStyle()
    .set(background: .red)
    .set(textFont: .systemFont(ofSize: 18))
    .set(textColor: .systemTeal)
    .set(cornerRadius: CometChatCornerStyle(cornerRadius: 8.0))
    .set(borderColor: .systemBlue)
    .set(borderWidth: 5)
    .set(outerViewWidth: 3)
    .set(outerViewSpacing: 3)

    let cometChatOutgoingCall = CometChatOutgoingCall()
    .set(avatarStyle: avatarStyle)
    ```
  </Tab>
</Tabs>

##### 3. Button Styles

To apply customized styles to the `Button` component in the OutgoingCall Component, you can use the following code snippet.

<Tabs>
  <Tab title="Swift">
    ```swift Swift theme={null}
    // Creating  AvatarStyle object
    let buttonStyle = ButtonStyle()
    .set(background: .red)
    .set(textFont: .systemFont(ofSize: 18))
    .set(textColor: .systemTeal)
    .set(cornerRadius: CometChatCornerStyle(cornerRadius: 8.0))
    .set(borderColor: .systemBlue)
    .set(borderWidth: 5)
    .set(iconBackground: .systemTeal)
    .set(iconBorder: 6)
    .set(iconCornerRadius: 10)
    .set(iconTint: .blue)

    let cometChatOutgoingCall = CometChatOutgoingCall()
    .set(buttonStyle: buttonStyle)
    ```
  </Tab>
</Tabs>

<Note>
  Ensure to pass and present `CometChatOutgoingCall`. If a navigation controller is already in use, utilize the pushViewController function instead of directly presenting the view controller.
</Note>

***

### Functionality

These are a set of small functional customizations that allow you to fine-tune the overall experience of the component. With these, you can change text, set custom icons, and toggle the visibility of UI elements.

**Example**

In this example, we're enhancing the interface by customizing the decline button icons. By setting custom icons for decline buttons, users can enjoy a more visually appealing and personalized experience.

This level of customization allows developers to tailor the user interface to match the overall theme and branding of their application.

<Frame>
  <img src="https://mintcdn.com/cometchat-013b37f0/cjVyusI_GGBVqQQt/images/19ea4d02-Outgoing_call_functionality_screens-7ff289997278f07ef47ee8f7bf1fb962.png?fit=max&auto=format&n=cjVyusI_GGBVqQQt&q=85&s=6661af28e5e99fa22b6785befb1e3639" width="4948" height="3120" data-path="images/19ea4d02-Outgoing_call_functionality_screens-7ff289997278f07ef47ee8f7bf1fb962.png" />
</Frame>

<Tabs>
  <Tab title="Swift">
    ```swift View controller theme={null}
    import UIKit
    import CometChatSDK
    import CometChatUIKitSwift
    import CometChatCallsSDK

    class ViewController: UIViewController, CometChatCallDelegate {
        func onIncomingCallReceived(incomingCall: CometChatSDK.Call?, error: CometChatSDK.CometChatException?) {

        }

        func onOutgoingCallAccepted(acceptedCall: CometChatSDK.Call?, error: CometChatSDK.CometChatException?) {

        }

        func onOutgoingCallRejected(rejectedCall: CometChatSDK.Call?, error: CometChatSDK.CometChatException?) {

        }

        func onIncomingCallCancelled(canceledCall: CometChatSDK.Call?, error: CometChatSDK.CometChatException?) {

        }

        override func viewDidLoad() {
            super.viewDidLoad()

            CometChat.calldelegate = self

            let receiverID = "your-uid"
            let receiverType: CometChat.ReceiverType = .user
            let callType: CometChat.CallType = .audio

            let newCall = Call(receiverId: receiverID, callType: callType, receiverType: receiverType)

            CometChat.initiateCall(call: newCall, onSuccess: { (ongoing_call) in
                print("Call initiated successfully " + ongoing_call!.stringValue())

                DispatchQueue.main.async {
                    let cometChatOutgoingCall = CometChatOutgoingCall()
                        .set(declineButtonIcon: UIImage(systemName: "iphone.slash")!)
                        .set(call: ongoing_call!)

                    cometChatOutgoingCall.modalPresentationStyle = .fullScreen

                    self.present(cometChatOutgoingCall, animated: true)
                }
            },             onError: { (error) in

                print("Call initialization failed with error:  \(error!.errorDescription)")
            })
        }
    }
    ```
  </Tab>
</Tabs>

<Note>
  If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
</Note>

Below is a list of customizations along with corresponding code snippets

| Property                | Description                                              | Code                               |
| ----------------------- | -------------------------------------------------------- | ---------------------------------- |
| **Call**                | Sets the Call object for CometChatOutgoingCall.          | `.set(call: Call)`                 |
| **SoundForCalls**       | Disables the default sound for calls.                    | `.disable(soundForCalls: Bool)`    |
| **CustomSoundForCalls** | Sets a custom sound for calls.                           | `.set(customSoundForCalls: URL?)`  |
| **DeclineButtonIcon**   | Sets the icon for the decline button in the call screen. | `.set(declineButtonIcon: UIImage)` |
| **User**                | Sets the User object for CometChatOutgoingCall.          | `.set(user: User)`                 |

### Advanced

For advanced-level customization, you can set custom views to the component. This lets you tailor each aspect of the component to fit your exact needs and application aesthetics. You can create and define your views, layouts, and UI elements and then incorporate those into the component.

The `OutgoingCall` component does not provide additional functionalities beyond this level of customization.

***

***
