Outgoing Call
Overview
The Outgoing Call
Component 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.

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.
- Swift
let cometChatOutgoingCall = CometChatOutgoingCall()
cometChatOutgoingCall.set(call: call)
cometChatOutgoingCall.modalPresentationStyle = .fullScreen
self.present(cometChatOutgoingCall, animated: true)
If you are already using a navigation controller, you can use the pushViewController
function instead of presenting the view controller.
Actions
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.
- Swift
let cometChatOutgoingCall = CometChatOutgoingCall()
cometChatOutgoingCall.set(onCancelClick: { call, controller in
//Perform Your Action
})
2. OnError
You can customize this behavior by using the provided code snippet to override the On Error
and improve error handling.
- Swift
let incomingCallConfiguration = CometChatOutgoingCall()
.set(onError:{ error in
//Perform Your Action
})
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 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. |
- Add Listener
// 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
}
}
//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)
- Remove Listener
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")
}
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.
Global level styling
- Swift
let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 8)
CometChatOutgoingCall.style.nameLabelFont = UIFont(name: "Times-New-Roman", size: 20)
CometChatOutgoingCall.style.callLabelFont = UIFont(name: "Times-New-Roman", size: 14)
CometChatOutgoingCall.style.declineButtonCornerRadius = .init(cornerRadius: 8)
CometChatOutgoingCall.avatarStyle = customAvatarStyle
Instance level styling
- Swift
let customAvatarStyle = AvatarStyle()
customAvatarStyle.backgroundColor = UIColor(hex: "#FBAA75")
customAvatarStyle.cornerRadius = CometChatCornerStyle(cornerRadius: 8)
let outgoingCallStyle = OutgoingCallStyle()
outgoingCallStyle.nameLabelFont = UIFont(name: "Times-New-Roman", size: 20)
outgoingCallStyle.callLabelFont = UIFont(name: "Times-New-Roman", size: 14)
outgoingCallStyle.declineButtonCornerRadius = .init(cornerRadius: 8)
let outgoingCall = CometChatOutgoingCall()
outgoingCall.style = outgoingCallStyle
outgoingCall.avatarStyle = customAvatarStyle

List of properties exposed by OutgoingCallStyle
Property | Description | Code |
---|---|---|
backgroundColor | Sets the background color for the outgoing call view. | CometChatOutgoingCall.style.backgroundColor = UIColor() |
borderColor | Sets the border color for the outgoing call view. | CometChatOutgoingCall.style.borderColor = UIColor.clear |
borderWidth | Sets the border width for the outgoing call view. | CometChatOutgoingCall.style.borderWidth = 0 |
cornerRadius | Sets the corner radius for the outgoing call view. | CometChatOutgoingCall.style.cornerRadius = .init(cornerRadius: 0) |
nameTextColor | Sets the text color for the name label in the outgoing call view. | CometChatOutgoingCall.style.nameTextColor = UIColor() |
nameTextFont | Sets the font for the name label in the outgoing call view. | CometChatOutgoingCall.style.nameTextFont = UIFont() |
callTextColor | Sets the text color for the call label in the outgoing call view. | CometChatOutgoingCall.style.callTextColor = UIColor() |
callTextFont | Sets the font for the call label in the outgoing call view. | CometChatOutgoingCall.style.callTextFont = UIFont() |
declineButtonBackgroundColor | Sets the background color for the decline button in the outgoing call view. | CometChatOutgoingCall.style.declineButtonBackgroundColor = UIColor() |
declineButtonIconTint | Sets the tint color for the decline button icon. | CometChatOutgoingCall.style.declineButtonIconTint = UIColor() |
declineButtonIcon | Sets the icon for the decline button. | CometChatOutgoingCall.style.declineButtonIcon = UIImage(systemName: "phone.down.fill") |
declineButtonCornerRadius | Sets the corner radius for decline button. | CometChatOutgoingCall.style.declineButtonCornerRadius: CometChatCornerStyle? |
declineButtonBorderColor | Sets the border color for decline button. | CometChatOutgoingCall.style.declineButtonBorderColor: UIColor? |
declineButtonBorderWidth | Sets the border width for decline button. | CometChatOutgoingCall.style.declineButtonBorderWidth: CGFloat? |
Functionality
These are a set of small functional customizations that allow you to fine-tune the overall experience of the component.
Property | Description | Code |
---|---|---|
disableSoundForCalls | Disables sound for outgoing calls. | disableSoundForCalls = true |
setCustomSoundForCalls | Sets a custom sound for outgoing calls. | set(customSoundForCalls: URL) |
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.
SetAvatarVieww
With this function, you can assign a custom view to the avatar of OutgoingCall Component.
- Swift
cometChatOutgoingCall.set(avatarView: { call in
let customView = CustomAvatarView()
return customView
})
Demonstration

You can create a CustomAvatarView as a custom UIView
.
import UIKit
class CustomAvatarView: UIView {
private let imageView: UIImageView = {
let imageView = UIImageView(image: UIImage(named: "user_profile")) // Replace with actual image
imageView.contentMode = .scaleAspectFill
imageView.layer.cornerRadius = 50
imageView.layer.masksToBounds = true
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
private let badgeView: UIView = {
let view = UIView()
view.backgroundColor = .yellow
view.layer.cornerRadius = 14
view.translatesAutoresizingMaskIntoConstraints = false
return view
}()
private let starIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(systemName: "star.fill"))
imageView.tintColor = .white
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
private func setupView() {
translatesAutoresizingMaskIntoConstraints = false
addSubview(imageView)
addSubview(badgeView)
badgeView.addSubview(starIcon)
NSLayoutConstraint.activate([
imageView.centerXAnchor.constraint(equalTo: centerXAnchor),
imageView.centerYAnchor.constraint(equalTo: centerYAnchor),
imageView.widthAnchor.constraint(equalToConstant: 100),
imageView.heightAnchor.constraint(equalToConstant: 100),
badgeView.trailingAnchor.constraint(equalTo: imageView.trailingAnchor, constant: 5),
badgeView.bottomAnchor.constraint(equalTo: imageView.bottomAnchor, constant: 5),
badgeView.widthAnchor.constraint(equalToConstant: 28),
badgeView.heightAnchor.constraint(equalToConstant: 28),
starIcon.centerXAnchor.constraint(equalTo: badgeView.centerXAnchor),
starIcon.centerYAnchor.constraint(equalTo: badgeView.centerYAnchor),
starIcon.widthAnchor.constraint(equalToConstant: 14),
starIcon.heightAnchor.constraint(equalToConstant: 14)
])
}
}
SetCancelView
You can modify the cancel call view of a Outgoing call component using the property below.
- Swift
cometChatOutgoingCall.set(cancelView: { call in
let view = CustomCancelView()
return view
})
Demonstration

You can create a CustomCancelView as a custom UIView
.
- Swift
import UIKit
class EndCallButton: UIButton {
private let phoneIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(systemName: "phone.down.fill"))
imageView.tintColor = .white
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
private func setupView() {
setTitle("End Call", for: .normal)
setTitleColor(.white, for: .normal)
backgroundColor = .red
layer.cornerRadius = 10
titleLabel?.font = UIFont.systemFont(ofSize: 18)
translatesAutoresizingMaskIntoConstraints = false
let stackView = UIStackView(arrangedSubviews: [phoneIcon, titleLabel!])
stackView.axis = .horizontal
stackView.spacing = 5
stackView.alignment = .center
stackView.translatesAutoresizingMaskIntoConstraints = false
addSubview(stackView)
NSLayoutConstraint.activate([
stackView.centerXAnchor.constraint(equalTo: centerXAnchor),
stackView.centerYAnchor.constraint(equalTo: centerYAnchor)
])
addTarget(self, action: #selector(endCallTapped), for: .touchUpInside)
}
@objc private func endCallTapped() {
print("Call Ended")
}
}
SetTitleView
You can customize the title view of a outgoing call component using the property below.
- Swift
cometChatOutgoingCall.set(titleView: { call in
let view = CustomTitleView()
view.configure(call:call)
return view
})
Demonstration

You can create a CustomTitleView
as a custom UIView
. Which we will inflate in setTitleView()
- Swift
import UIKit
class CustomTitleView: UILabel {
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
private func setupView() {
font = UIFont.boldSystemFont(ofSize: 22)
textAlignment = .center
translatesAutoresizingMaskIntoConstraints = false
}
func configure(call:Call){
text = "\(call.callInitiator <> \(call.receiver))"
}
}
SetSubtitleView
You can modify the subtitle view of a outgoing call component using the property below.
- Swift
cometChatOutgoingCall.set(subtitleView: { call in
let view = CustomSubtitleView()
return view
})
Demonstration

You can create a CustomSubtitleView as a custom UIView
.
- Swift
import UIKit
class CustomSubtitleView: UIStackView {
private let phoneIcon: UIImageView = {
let imageView = UIImageView(image: UIImage(systemName: "phone.fill"))
imageView.tintColor = .gray
imageView.translatesAutoresizingMaskIntoConstraints = false
return imageView
}()
private let callingLabel: UILabel = {
let label = UILabel()
label.text = "Calling..."
label.textColor = .gray
label.font = UIFont.systemFont(ofSize: 18)
label.translatesAutoresizingMaskIntoConstraints = false
return label
}()
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init(coder: NSCoder) {
super.init(coder: coder)
setupView()
}
private func setupView() {
axis = .horizontal
spacing = 5
alignment = .center
translatesAutoresizingMaskIntoConstraints = false
addArrangedSubview(phoneIcon)
addArrangedSubview(callingLabel)
}
}