Connect Your User Base Using The ZEGOCLOUD Call Kit
Tags: callkit, developers, zegocloud
Published: 2022-11-11 06:54:51

Managing the user base of apps, along with the relationship chain, is an important point. 

Depending on their scope, apps operate their lists; communication apps have contact lists, social media lists of followers, and business app lists of customers and partners.
You are in the right place for those who have a user base and intend to connect it to **ZEGOCLOUD Call Kit** to incorporate invitations and calls.
So let's look together at the instructions for configuration.


**Audio and video call process**
Before explaining the connection between the App User List and the ZEGOCLOUD Call Kit system, you need to understand the call process.
A complete call process comprehends three steps:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pozb26c7f0h60l69o2y2.png)

**1）Sign in**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4zslq7p7hi2ts0spa4lw.png)

First, your App will access its business service to complete user authentication and sign in. At this point, your App has obtained the sign-in user information from the business service.
Secondly, you can call the API of the ZEGOCLOUD Call Kit to connect the user with the ZEGOCLOUD Real-time Network so that the ZEGOCLOUD Real-time Network can communicate with the user.
If the user is online, he will always connect to the Real-time Network, and when someone else invites him to talk, he will receive a notification through the connection.
If the user is offline, ZEGOCLOUD Real-time Network can send a notification through APNS and FCM, allowing the user to wake up the App to answer the call.

**2) Call invitation**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oajfz8n9lbtwokyinq1s.png)

Before your user initiates a call invitation, you must first ensure that the App user list is on the App – such as the contact list, follower list, and customer list – and then select the call object from the user list.
Call the API of ZEGOCLOUD Call Kit, pass the user ID of the callee to Call Kit, and then initiate a call. The callee will receive an invitation notification, and the ZEGOCLOUD Call Kit will play the call ringtone and display the message.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oftts9ujb9aulhqwo6qc.png)

**3) Start Call**


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b3gyv1x0mci2tvhpwj7.png)

As shown in the figure, the logic of starting a call is implemented by the ZEGOLCOUD Call Kit.
When the callee clicks the accept invitation button, ZEGOCLOUD Call Kit will send the caller a message to accept the call, and the two will enter the call interface and start the call.


## **
How to implement the call process**

The following step-by-step process shows how to implement the connection between the App User list and the ZEGOCLOUD Call Kit.
**Preparation**
Before you start accessing the App user list, you need to complete the following steps:
- A ZEGOCLOUD developer account — Sign up
- Refer to the Access Guide to complete the SDK introduction
**1）Sign in**
First, after the user signs in successfully, call the initWithAppID
 method to connect the user to the ZEGOCLOUD Real-time Server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/01iq3myc9hfzusdn18ks.png)

Pay attention. Your App may remember the user's signed-in state. When the users launch the App next time, they can use the app functions directly without signing in.
So you need to check the user’s sign-in status when the application launches. If the user is signed-in, call initWithAppID
 to connect the user to the ZEGOCLOUD Real-time Server.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/38edgvrgpxodrh7ygeea.png)

**2）Call Invitation**
When the user logs in successfully, and the App obtains the App User List, then the call logic can be added, and the user ID of the callee can be passed to the ZEGOCLOUD Call Kit.
ZEGOCLOUD Call Kit encapsulates the call button, you only need to display the call button on the interface, and pass the user ID of the callee to ZegoStartCallInvitationButton.inviteeList
.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/17bsxadm0gf9jogg4yzd.png)

**- Add The Call Button**

Create a new call button ZegoStartCallInvitationButton
 and add the button to the interface.
var callButton = ZegoStartCallInvitationButton(.videoCall)
self.contentView.addSubview(callButton)

**- Pass the called user information**

Pass the user information of the callee to ZegoStartCallInvitationButton.inviteeList
, you can pass one user information or multiple user information. If it is multiple user information, it will be a group call.
let zegoUser: ZegoUIkitUser = ZegoUIkitUser(user.userID, user.userName)
callButton.inviteeList = [zegoUser]

Sometimes the application is in the background or closed state; we define this state as the offline state. In order to initiate calls to these users, offline messages need to be notified through APNS , FCM, and other channels. ZEGOCLOUD Call Kit supports offline calls, and I will explain how to configure offline calls in subsequent articles.

**Start Call**

ZEGOCLOUD Call Kit encapsulates call notification and calls processing logic. When the callee receives the call invitation, the ZEGOCLOUD Call Kit will pop up on the call notification page, and the callee only needs to click the accept call button to start the call.
So just complete the two steps of User Login and Call Invitation to complete the Video Call App.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ml3bwi9xc76cjg47wfar.png)

Run a [DEMO](https://www.youtube.com/watch?v=7DnTKypsOKs).


**To finalize the two steps of User Login and Call Invitation, complete the Video Call App.**

## Conclusion

Users are the main component in Video Call apps. 
You can link the user list to the ZEGOCLOUD Call Kit system with only UserID and UserName information.
It gives you ample room for maneuvering in creating these lists; moreover, you can devote the time saved by using the ZEGOCLOUD Call Kit to perfect the Video Call function.
What are you waiting for? Download the sample source code for this article now. 
Good work!