Talk to us
Talk to us
menu

How to Connect User Base Using Call Kit

How to Connect User Base Using Call Kit

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.dome disco avec toboggan

A complete call process comprehends three steps:

audio and video call process

Understanding each step’s processing logic lets, you know how to connect the App user list to the ZEGOCLOUD Call Kit. Below I will explain the logic step by step.

1)Sign in

sign in
sign-in

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

call invitation

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.

call invitation demo

3) Start Call

start call

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 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:

1)Sign in

First, after the user signs in successfully, call the initWithAppID method to connect the user to the ZEGOCLOUD Real-time Server.

sign in code
public func registerUserInfo() {
    let appID: UInt32 = <#YouAppID#>
    let appSign = <#YourAppSign#>
    let userID = UserManager.shared.loginUser?.userID ?? ""
    let userName = UserManager.shared.loginUser?.userName ?? ""

    let config = ZegoUIKitPrebuiltCallInvitationConfig([ZegoUIKitSignalingPlugin()])
    ZegoUIKitPrebuiltCallInvitationService.shared.initWithAppID(appID, appSign: appSign, userID: userID, userName: userName, config: config)
    ZegoUIKitPrebuiltCallInvitationService.shared.delegate = self
}

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.

auto sign in code

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.

  • Add The Call Button

Create a new call button ZegoStartCallInvitationButton and add the button to the interface.

var callButton = ZegoStartCallInvitationButton(1)
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.

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

Run a Demo

Conclusion

Users are the main component of video chat apps. You can link the user list to the ZEGOCLOUD Call Kit system with only UserID and UserName. 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.

Read More:

Let’s Build APP Together

Start building with real-time video, voice & chat SDK for apps today!

Talk to us

Take your apps to the next level with our voice, video and chat APIs

Free Trial
  • 10,000 minutes for free
  • 4,000+ corporate clients
  • 3 Billion daily call minutes

Stay updated with us by signing up for our newsletter!

Don't miss out on important news and updates from ZEGOCLOUD!

* You may unsubscribe at any time using the unsubscribe link in the digest email. See our privacy policy for more information.