Skip to main content

Overview

This guide demonstrates how to start One on One call in to an iOS application. Before you begin, we strongly recommend you read the calling setup guide.

Generate Token

To start the call you need callToken and sessionID. SessionID is something you can define to identify your call, it can be a random string or any thing that is defined by the user. For that SessionID you need to generate callToken using Calls SDK. Generate token method takes two parameter authToken and sessionId. authToken: User can get the auth token from CometChatSDK that has a static method getUsersAuthToken(). sessionId: Any random string.
Call Settings Next you have to create your own CallSettingsBuilder by defining the properties you need in that call. The CallSettings class is the most important class when it comes to the implementation of the Calling feature. This is the class that allows user to customize the overall calling experience. The properties for the call/conference can be set using the CallSettingsBuilder class. This will eventually give user an object of the CallSettings class which user can pass to the startCall() method to start the call. The mandatory parameters that are required to be present for any call/conference to work are:
  1. UIView i.e a view in which user want to show the calling view inside it.
  2. Video Settings.

Start Call Session

To start a call, user have to pass callToken, callSettings and callView. callToken In the success block of generateToken(), user get the callToken. callSettings CallSettings can be set from the CallSettingsBuilder callView callView is a UIView in which you want to display the call UI

End Call Session

To release the acquired calling resource and end the call, the end call session must be called.

For Default Call

You only need to call the end call method of the chat SDK for default calling flows. Direct calling flows do not require it.
To end a call in the default call flow, you must call the CometChat.endCall() method, which belongs to the CometChat Chat SDK, and the CometChatCalls.endSession() method, which belongs to the CometChat Calls SDK. The user who pressed the end call button will call the CometChat.endCall() method, and the another user how was on call will call the two methods which is CometChat.clearActiveCall() and CometChatCalls.endSession() methods to release the calling resources
The user who ended the call
The another user who was on call

For Direct Call

Calling Events Listners To get calling events, User have to conform the “CallsEventsDelegate” delegate. For these events working, User have to pass “self” to setDelegate() in callSettingsBuilder.
  • Before v4.1.2: Events were returned as NSDictionary objects with key-value pairs
  • From v4.1.2 onwards: Events are returned as structured objects with defined properties and enumerated types

MultiListener For Call Events

Through Multi Listener you can get Inn-call events in any class that accepts CallsEventsDelegate Add listener for a calls
Remove listener for a calls
On removing the listener, user will not get callbacks for call events for that particular unique ID associated class

Custom Events

In case user wish to achieve a completely customized UI for the Calling experience, user can do so by embedding default iOS buttons to the screen as per requirements and then use the below methods to achieve different functionalities for the embedded buttons. For the use case where user wish to align own custom buttons and not use the default layout provided by CometChat, user can embed the buttons in the layout and use the below methods to perform the corresponding operations:

Switch Camera

User can end the call by using the CometChatCalls.switchCamera()

Audio Muted

User can end the call by using the audioMuted(true)
Audio Unmute User can end the call by using the audioMuted(false)
Pause Video User can end the call by using the videoPaused(true)

Unpause Video

User can end the call by using the videoPaused(false)
Set Audio Mode User can end the call by using the setAudioMode(mode: "**_**MODE**_**")
Available since v4.1.2

Enter PIP Mode

User can end the call by using the enterPIPMode()

Exit PIP Mode

User can end the call by using the exitPIPMode()

SwitchToVideoCall

User can end the call by using the switchToVideoCall()

Strat Recording

User can end the call by using the startRecording()

Stop Recording

User can end the call by using the stopRecording()