> ## 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.

# Call Buttons

> Voice and video call buttons that start a 1:1 call or a group meeting, on the Kit's call screens or your own.

`CometChatCallButtons` shows a voice and a video button for a user or a group. A tap
starts the call: a 1:1 call that rings the other user, or a group meeting by sending a
`meeting` message to the group. The message header uses it for its call region.

![CometChatCallButtons showing voice and video call buttons](https://mintcdn.com/cometchat-22654f5b/pWDsskjSUHgot30F/images/ui-kit/ios/v6/docs-overview-call-buttons.png?fit=max\&auto=format\&n=pWDsskjSUHgot30F\&q=85\&s=c93815762b03b7775a61510fdcaa025f)

***

## Where It Fits

`CometChatCallButtons` is the call entry point for a conversation. Give it a user or a group
and it starts the call; the Kit presents the call on its own call screens, or hands the call
to you to show yourself.

***

## Quick Start

With calling on, the buttons place the call and show it themselves.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatCallButtons(user: user)
> ```
>
> The screen is `.cometChatCallPresenter()`'s when your app installs it at its root, otherwise
> the buttons' own full-screen cover.

> [tab] UIKit
>
> ```swift theme={null}
> let buttons = CometChatCallButtons()
> buttons.set(user: user)
> ```
>
> `CometChatCallButtons` is a `UIStackView`. The screen is `CometChatCallPresenter`'s when your
> app has started it, otherwise presented full screen from the buttons' view controller.

* **A user** — the Kit places a 1:1 call and shows it ringing on
  [`CometChatOutgoingCall`](https://www.cometchat.com/docs/ui-kit/ios/v6/outgoing-call); when the callee answers,
  that screen becomes the call.
* **A group** — the Kit sends a `meeting` custom message and joins that meeting on
  [`CometChatOngoingCall`](https://www.cometchat.com/docs/ui-kit/ios/v6/ongoing-call). Group calls do not ring.

See [Call Features](https://www.cometchat.com/docs/ui-kit/ios/v6/call-features.md).

***

## Actions and Events

### Callback Methods

#### Showing the Call Yourself

`onCallInitiated` and `onStartDirectCall` replace the Kit's screens. You get the placed
`Call`, or the meeting message, and show it yourself.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatCallButtons(
>     user: user,
>     onCallInitiated: { call in presentMyCallScreen(for: call) },
>     onStartDirectCall: { meeting in joinMyMeeting(meeting) }
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> buttons.set(onCallInitiated: { call in presentMyCallScreen(for: call) })
> buttons.set(onStartDirectCall: { meeting in joinMyMeeting(meeting) })
> ```
>
> The matching delegate methods replace the Kit's screens in the same way.

> [!NOTE]
>
> The buttons render only when something can show the call: the Kit built with the Calls SDK
> and calling turned on (`CometChatSession.initialize(…, enableCalling: true)`), or a click
> handler, `onCallInitiated` or `onStartDirectCall` set.

#### Taking the Tap Yourself

A click handler replaces the call entirely — the Kit starts nothing.

> [tab] SwiftUI
>
> ```swift theme={null}
> CometChatCallButtons(
>     group: group,
>     onVoiceCallClick: { user, group in startMyCall(user: user, group: group, video: false) },
>     onVideoCallClick: { user, group in startMyCall(user: user, group: group, video: true) }
> )
> ```

> [tab] UIKit
>
> ```swift theme={null}
> buttons.set(onVoiceCallClick: { user, group in startMyCall(user: user, group: group, video: false) })
> buttons.set(onVideoCallClick: { user, group in startMyCall(user: user, group: group, video: true) })
> ```

#### Errors

A failure goes to `onError`. With no user or group the error is `INVALID_RECEIVER`.
After a failure the buttons stay in the error state until the next call succeeds, and a
second tap while a call is starting starts another.

> [tab] SwiftUI
>
> `onError` has the signature `(CometChatError) -> Void`.

> [tab] UIKit
>
> `set(onError:)` has the signature `(CometChatException) -> Void`.

### Global Events

A 1:1 call also emits an outgoing-call event.

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

> [tab] UIKit
>
> The Kit sends `ccOutgoingCall` to [`CometChatCallEvents`](https://www.cometchat.com/docs/ui-kit/ios/v6/events) listeners.

***

## Functionality

> [tab] SwiftUI
>
> | Parameter | Type | Default |
> | - | - | - |
> | `user`, `group` | `CometChatSDK.User?`, `CometChatSDK.Group?` | `nil` |
> | `store` | `CallButtonsStore?` | a new store |
> | `hideVoiceCallButton`, `hideVideoCallButton` | `Bool` | `false` |
> | `voiceButtonText`, `videoButtonText` | `String?` | `nil` — a label beside the icon |
> | `hideButtonText` | `Bool` | `true` — turn off to show the labels |
> | `hideButtonIcon` | `Bool` | `false` |
> | `onVoiceCallClick`, `onVideoCallClick` | `(User?, Group?) -> Void` | — |
> | `onCallInitiated` | `(Call) -> Void` | — |
> | `onStartDirectCall` | `(BaseMessage) -> Void` | — |
> | `onError` | `(CometChatError) -> Void` | — |
> | `style` | `CometChatCallButtonsStyle` | `.init()` |
>
> ```swift theme={null}
> CometChatCallButtons(
>     user: user,
>     voiceButtonText: "Voice", videoButtonText: "Video",
>     hideButtonText: false,
>     onCallInitiated: { presentMyCallScreen(for: $0) }
> )
> ```

> [tab] UIKit
>
> | Member | Type | Default |
> | - | - | - |
> | `set(user:)`, `set(group:)` | `User`, `Group` | — |
> | `set(store:)` | `CallButtonsStore` | a new store |
> | `hideVoiceCallButton`, `hideVideoCallButton` | `Bool` | `false` |
> | `hideButtonText` | `Bool` | `true` |
> | `hideButtonIcon` | `Bool` | `false` |
> | `hideButtonBackground`, `hideVoiceCallButtonBackground`, `hideVideoCallButtonBackground` | `Bool` | `true` |
> | `voiceCallIconText`, `videoCallIconText` | `String?` | `nil` — a label under the icon |
> | `set(onVoiceCallClick:)`, `set(onVideoCallClick:)` | `(User?, Group?) -> Void` | — |
> | `set(onCallInitiated:)` | `(Call) -> Void` | — |
> | `set(onStartDirectCall:)` | `(BaseMessage) -> Void` | — |
> | `set(onError:)` | `(CometChatException) -> Void` | — |
>
> ```swift theme={null}
> buttons.voiceCallIconText = "Voice"          // a label under the icon
> buttons.videoCallIconText = "Video"
> buttons.hideButtonBackground = false          // a disc behind each icon
> buttons.voiceCallButtonBackgroundTint = .systemGreen.withAlphaComponent(0.15)
> ```
>
> Setting a text shows its label; `hideButtonText` switches both labels off or on, whichever
> was set last.

***

## Advanced Methods

### Store Access

`CallButtonsStore` is the part that starts calls.

> [tab] SwiftUI
>
> Pass one to `store` to observe its `state` — `idle`, `initiating` or `error` — or to share it.

> [tab] UIKit
>
> Pass one to `set(store:)` to observe its `state` — `idle`, `initiating` or `error` — or to
> share it.

### Delegate

> [tab] SwiftUI
>
> `CometChatCallButtons` is a `View` struct and has no delegate. Use its callbacks.

> [tab] UIKit
>
> ```swift theme={null}
> final class CallHost: NSObject, CometChatCallButtonsDelegate {
>     func onCallInitiated(call: Call) { presentMyCallScreen(for: call) }
>     func onError(error: NSError) { print(error.localizedDescription) }
> }
> ```
>
> `CometChatCallButtons` is usable from Objective-C.

### Subclassing

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

> [tab] UIKit
>
> These override points are `open`: `setupStyle()`, `buildButton(forUser:)`,
> `buildButton(forGroup:)` and `startGroupCall(sessionID:group:isVideoCall:)` — by default, the
> last sends the meeting message.

***

## Style

> [tab] SwiftUI
>
> `CometChatCallButtonsStyle` holds one `CallButtonStyle` per button and the gap between
> them. Set only what you change:
>
> ```swift theme={null}
> var style = CometChatCallButtonsStyle()
> style.voiceCallButtonStyle = CallButtonStyle(iconTint: .green, backgroundColor: .green.opacity(0.12),
>                                              cornerRadius: 20, buttonPadding: 8)
> style.marginBetweenButtons = 16
>
> CometChatCallButtons(style: style, user: user, onCallInitiated: { presentMyCallScreen(for: $0) })
> ```
>
> | `CallButtonStyle` | Default |
> | - | - |
> | `icon`, `iconTint`, `iconSize` | `phone` / `video` in `iconTintPrimary`, natural size |
> | `textColor`, `textStyle` | `iconTintPrimary`, `bodyRegular` |
> | `backgroundColor`, `cornerRadius` | clear, 0 |
> | `strokeWidth`, `strokeColor` | none — drawn only above zero |
> | `buttonPadding` | 0 |
> | `marginBetweenButtons` | 8 |

> [tab] UIKit
>
> ```swift theme={null}
> let style = CallButtonStyle()
> style.voiceCallButtonStyle.iconTint = .systemGreen
> style.voiceCallButtonStyle.cornerRadius = 20
> style.voiceCallButtonStyle.buttonPadding = 8
> style.marginBetweenButtons = 16
> buttons.set(style: style)
> ```
>
> Each `CallButtonItemStyle` has `icon`, `iconTint`, `iconSize`, `textColor`,
> `textFont`, `backgroundColor`, `cornerRadius`, `strokeWidth`, `strokeColor` and
> `buttonPadding`. Set `CometChatCallButtons.style` for every instance.

***

## Next Steps

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

> [card] [Ongoing Call](https://www.cometchat.com/docs/ui-kit/ios/v6/ongoing-call.md)
>
> The screen a group meeting opens

> [card] [Call Features](https://www.cometchat.com/docs/ui-kit/ios/v6/call-features.md)
>
> Set up calling in your app

> [card] [Message Header](https://www.cometchat.com/docs/ui-kit/ios/v6/message-header.md)
>
> The header that embeds the call buttons


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