> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Ongoing Call

> The call itself: the Calls SDK's call view, with the Kit's connecting spinner and failure state over it.

`CometChatOngoingCall` is the call itself: the CometChat Calls SDK's own call view — video
tiles, mute, camera and end controls — with a spinner over it while it connects, and "Call
failed" if the join fails. It shows a 1:1 call once it is answered, a group meeting, or a call
answered from CallKit.

![CometChatOngoingCall while the call connects](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-ongoing-call.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=2c148ef873dec73f7d7ac2f59dbad815)

***

## Where It Fits

```
outgoing call answered ─┐
meeting Join / group tap ┼─▶ ┌────────────────────────────┐ ─ ended ─▶ onCallEnded / dismissed
answered on CallKit ─────┘   │ CometChatOngoingCall ← here │
                             └────────────────────────────┘
```

The Kit shows this screen for every call it starts or answers — the call buttons, the call
log's call-back, a meeting bubble's **Join**, and a call answered from CallKit. See
[Call Features](https://www.cometchat.com/docs/ui-kit/ios/v6/call-features.md).

> [tab] SwiftUI
>
> The screen is shown through `.cometChatCallPresenter()` when your app installs it, otherwise
> from the component that started the call.

> [tab] UIKit
>
> The screen is presented through `CometChatCallPresenter` when your app has started it,
> otherwise from the component that started the call.

***

## Quick Start

For a call your app placed or answered itself, show its session.

> [tab] SwiftUI
>
> ```swift theme={null}
> struct CallScreen: View {
>     let call: Call
>     @Environment(\.dismiss) private var dismiss
>
>     var body: some View {
>         CometChatOngoingCall(sessionId: call.sessionID ?? "", callType: .video,
>                              onCallEnded: { dismiss() })
>     }
> }
> ```
>
> The screen finds the call before it joins anything: the `store` you pass; else the Kit's
> current call for `sessionId`; else it joins `sessionId` through the Kit's `CallCoordinator`,
> so your push integration hears about the join like any other.

> [tab] UIKit
>
> `CometChatOngoingCall` is a `UIViewController`.
>
> ```swift theme={null}
> let screen = CometChatOngoingCall()
>     .set(call: placedCall)
>     .setOnCallEnded { call in log("call \(call.sessionID ?? "") ended") }
> screen.modalPresentationStyle = .fullScreen
> present(screen, animated: true)
> ```
>
> The screen finds the call before it joins anything: the `ongoingCallStore` you pass; else the
> Kit's current call for the session; else it joins the session through the Kit's
> `CallCoordinator`, so your push integration hears about the join like any other.

***

## Joining a Meeting

A group meeting is joined directly, with `.directCalling`. It ends only from its own leave
button, not when one member leaves.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatOngoingCall(sessionId: group.guid, callType: .voice, callWorkFlow: .directCalling)
> ```

> [tab] UIKit
>
> ```swift theme={null}
> let meeting = CometChatOngoingCall()
>     .set(sessionId: group.guid)
>     .set(callType: .voice)
>     .set(callWorkFlow: .directCalling)
> ```

| `callWorkFlow` | For | Ends |
| - | - | - |
| `.defaultCalling` | a ringing 1:1 call | when the session ends |
| `.directCalling` | a meeting | from its own leave button |

`callSettingsBuilder` takes the Calls SDK's `SessionSettingsBuilder`. It applies only to a
meeting this screen joins itself; any other call's settings were fixed when it was placed, so
the screen reports it once through `onError` instead.

***

## Actions and Events

### Callback Methods

> [tab] SwiftUI
>
> | Callback | Fires when | Default |
> | - | - | - |
> | `onCallEnded` | the call is over, or could not be joined — once | dismiss |
> | `onError` | the join failed, or `callSettingsBuilder` came too late | — |
>
> `onCallEnded` has the signature `() -> Void`; `onError` is `(CometChatError) -> Void`.

> [tab] UIKit
>
> | Callback | Fires when |
> | - | - |
> | `setOnCallEnded(onCallEnded:)` | the call is over, or could not be joined — once, with the call. The screen then dismisses itself |
> | `set(onError:)` | the join failed, a settings builder came too late, or the screen has no session |
>
> `set(onError:)` has the signature `(NSError) -> Void`.

### Global Events

Leaving the screen does not end the call.

> [tab] SwiftUI
>
> The Kit emits `callEnded` on [`CometChatEvents`](https://www.cometchat.com/docs/ui-kit/ios/v6/events) when the call ends.

> [tab] UIKit
>
> The Kit sends `ccCallEnded` to your [`CometChatCallEventListener`](https://www.cometchat.com/docs/ui-kit/ios/v6/events)
> when the call ends.

***

## Functionality

> [tab] SwiftUI
>
> | Parameter | Type | Default |
> | - | - | - |
> | `sessionId` | `String` | required |
> | `callType` | `CallKind` | `.voice` or `.video` |
> | `store` | `OngoingCallStore?` | the coordinator's call for `sessionId`, else a join |
> | `callWorkFlow` | `CallWorkFlow` | `.defaultCalling` |
> | `callSettingsBuilder` | `Any?` | `nil` |
> | `style` | `CometChatOngoingCallStyle` | `.init()` |
> | `onCallEnded` | `() -> Void` | dismiss |
> | `onError` | `(CometChatError) -> Void` | — |

> [tab] UIKit
>
> | Method | Does |
> | - | - |
> | `set(sessionId:)` | the session to join |
> | `set(call:)` | the call — its session, call type, and what `setOnCallEnded` hands back |
> | `set(callType:)` | a `CallKind` |
> | `set(callWorkFlow:)` | `.defaultCalling` or `.directCalling` |
> | `set(callSettingsBuilder:)` | the Calls SDK's `SessionSettingsBuilder`, for a meeting this screen joins |
> | `set(style:)` | sets the `CometChatOngoingCallStyle` |
>
> The initialiser is `CometChatOngoingCall(ongoingCallStore:)`; the store is optional.

***

## Advanced Methods

### Store Access

> [tab] SwiftUI
>
> `OngoingCallStore` is the call: its `call` (an `ActiveCall` — session, kind, title), its
> `state` (`connecting`, `joined`, `ended`, `failed`) and `leave()`. `CallCoordinator.shared.activeCall`
> is the call that is up now, if any.

> [tab] UIKit
>
> The view controller's store is `ongoingCallStore`, and `containerView` holds the Calls SDK's
> call view. `CallCoordinator.shared.activeCall` is the call that is up now, if any.

### Subclassing

> [tab] SwiftUI
>
> `CometChatOngoingCall` is a `View` struct. Customise it with its style.

> [tab] UIKit
>
> `buildUI()` and `setupStyle()` are the override points.

***

## Style

The Calls SDK draws the call; the Kit draws only what covers it while it connects and if it
fails.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatOngoingCall(sessionId: "SESSION_ID", callType: .video,
>                      style: CometChatOngoingCallStyle(backgroundColor: .black, progressIndicatorColor: .orange))
> ```
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | `#141414` |
> | `progressIndicatorColor` | `white` |
> | `failureTextColor`, `failureTextFont` | `white`, `bodyRegular` |
> | `cornerRadius`, `strokeWidth`, `strokeColor` | none |

> [tab] UIKit
>
> ```swift theme={null}
> CometChatOngoingCall.style.backgroundColor = .black
> CometChatOngoingCall.style.progressIndicatorColor = .systemOrange
> ```
>
> | Property | Default |
> | - | - |
> | `backgroundColor` | `#141414` |
> | `progressIndicatorColor` | `white` |
> | `failureTextColor`, `failureTextFont` | `white`, `bodyRegular` |
> | `cornerRadius`, `borderWidth`, `borderColor` | none |

***

## Next Steps

> [card] [Outgoing Call](https://www.cometchat.com/docs/ui-kit/ios/v6/outgoing-call.md)
>
> The ringing screen that becomes this call

> [card] [Call Buttons](https://www.cometchat.com/docs/ui-kit/ios/v6/call-buttons.md)
>
> Start a call or a group meeting

> [card] [Call Logs](https://www.cometchat.com/docs/ui-kit/ios/v6/call-logs.md)
>
> The calls the user has had

> [card] [Call Features](https://www.cometchat.com/docs/ui-kit/ios/v6/call-features.md)
>
> How calls ring and are presented


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.