The CometChatIncomingCall component serves as a visual representation when the user receives an incoming call, such as a voice call or video call, providing options to answer or decline the call.
CometChatIncomingCall is a custom view controller that 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
Report incorrect code
Copy
Ask AI
// Create and configure incoming call view controllerlet cometChatIncomingCall = CometChatIncomingCall().set(call: call)// Present full screencometChatIncomingCall.modalPresentationStyle = .fullScreenself.present(cometChatIncomingCall, animated: true)
If you are already using a navigation controller, you can use the pushViewController function instead of presenting the view controller.
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.
The setOnAcceptClick action is typically triggered when the user clicks on the accept button, initiating a predefined action. However, by implementing the following code snippet, you can easily customize or override this default behavior to suit your specific requirements.
Swift
Report incorrect code
Copy
Ask AI
let cometChatIncomingCall = CometChatIncomingCall() .set(onAcceptClick: { call, controller in // Perform your custom action when call is accepted })
The setOnCancelClick action is typically triggered when the user clicks on the reject button, initiating a predefined action. However, by implementing the following code snippet, you can easily customize or override this default behavior to suit your specific requirements.
Swift
Report incorrect code
Copy
Ask AI
let cometChatIncomingCall = CometChatIncomingCall() .set(onCancelClick: { call, controller in // Perform your custom action when call is rejected })
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 experience. Filters can be applied using RequestBuilders of Chat SDK.The IncomingCall component does not have any exposed filters.
Events are emitted by a Component. By using events 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 Incoming Call component are as follows:
Event
Description
onIncomingCallAccepted
Triggers when the logged-in user accepts the incoming call
onIncomingCallRejected
Triggers when the logged-in user rejects the incoming call
onCallEnded
Triggers when the initiated call successfully ends
Add Listener
Report incorrect code
Copy
Ask AI
// View controller from your project where you want to listen to eventspublic class ViewController: UIViewController { public override func viewDidLoad() { super.viewDidLoad() // Subscribe to call events CometChatCallEvents.addListener("UNIQUE_ID", self as CometChatCallEventListener) }}// Listener events from call moduleextension ViewController: CometChatCallEventListener { func onIncomingCallAccepted(call: Call) { // Handle accepted call } func onIncomingCallRejected(call: Call) { // Handle rejected call } func onCallEnded(call: Call) { // Handle ended call }}
Report incorrect code
Copy
Ask AI
// Emitting Call Events// Emit when logged in user accepts the incoming callCometChatCallEvents.emitOnIncomingCallAccepted(call: Call)// Emit when logged in user rejects the incoming callCometChatCallEvents.emitOnIncomingCallRejected(call: Call)// Emit when logged in user ends a callCometChatCallEvents.emitOnCallEnded(call: Call)
Remove Listener
Report incorrect code
Copy
Ask AI
public override func viewWillDisappear(_ animated: Bool) { // Unsubscribe from call events CometChatCallEvents.removeListener("LISTENER_ID_USED_FOR_ADDING_THIS_LISTENER")}
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.
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.
You can customize the appearance of the IncomingCall Component by applying the IncomingCallStyle to it using the following code snippet.Global level styling
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.