Introduction
With the continuous improvement of device performance and network quality, more and more audio and video call scenarios have been applied, and video call API has also been applied more and more.
What capabilities can the video call API provide?
With the increasing demand for video call API, there are more and more companies providing video call API, but the functions provided are similar.
The capabilities provided by the video call API mainly include the following:
- Call invitation
- Voice and Video call
- Offline push function
- Call UI and interaction
Below is a live video call app built using ZEGOCLOUD's video call API.
What is ZEGOCLOUD's video call API?
ZEGOCLOUD's video call API uses a layered architecture. Details are as shown in the figure below:
ZEGOCLOUD's video call API provides two different SDKs for you: the CallUIKit
and the Call SDK
.
CallUIKit
: Provide a complete live video call UI, you only need to call the call interface and hang up the interface where you need to complete the call process.
Call SDK
: Provides the underlying logic of live video calls, such as audio and video management, call management, network status management, etc. You only need to focus on the implementation of the upper-layer custom UI and call the corresponding interactive interface to complete the call process.
How to use ZEGOCLOUD's Video call API
Step 1. Create a ZEGOCLOUD account
- Create an account in ZEGOCLOUD Official.
Step 2. Create a new project
- Create a project in ZEGOCLOUD Admin Console.
Step 3. Create a Firebase project
Create a Firebase project in the Firebase console. For more details, see Firebase Documentation.
Step 4. Deploy the Firebase Cloud Functions
ZEGO Call uses the Firebase Cloud Functions as the business server by default, we recommend you activate and deploy it before integrating the ZEGOCall SDK.
Edit the rules of the Realtime Database by adding the following:
{
"rules": {
".read": "auth.uid != null",
".write": "auth.uid != null",
}
}
-
Install the CLI via npm.
npm install -g firebase-tools
Run the
firebase login
to log in via the browser and authenticate the firebase tool.
Run
firebase init functions
. The tool gives you an option to install dependencies with npm. It is safe to decline if you want to manage dependencies in another way, though if you do decline you'll need to run npm install before emulating or deploying your functions.
Download the Cloud function sample code.
Copy the
firebase.json
,functions\index.js
files andfunctions\token04
folder in the sample code to your cloud function project, overwrite files with the same name.
- Modify the
index.js
file, fill in the AppID and ServerSecret you get from ZEGOCLOUD Admin Console correctly.
- In Firebase CLI, run the
firebase deploy --only functions
command to deploy the cloud functions.
Step 5. Copy file into the project
To integrate the ZEGOCallUIKit automatically with CocoaPods, do the following:
Download the Sample codes, and copy the
ZEGOCallUIKit
andZEGOCall
folders to your project directory (if you have no project, create a new one).
-
Open Terminal, navigate to your project directory, run the
pod init
command to create aPodfile
, and then add the following to the file.
pod 'ZegoExpressEngine' pod 'FirebaseAuth' pod 'GoogleSignIn' pod 'Firebase/Database' pod 'Firebase/Analytics' pod 'Firebase/Crashlytics' pod 'Firebase/Messaging' pod 'Firebase/Functions'
-
In Terminal, navigate to the directory where the Podfile locates, and run the
pod install
command.
pod install
Restart the Xcode, and open the newly generated .workspace file.
Step 6. Add permissions
Permissions can be set as needed.
- Open Xcode, select the target object, and then click Info > Custom iOS Target Properties.
- Click the Add button (+) to add camera and microphone permissions.
Privacy-Camera Usage Description
Privacy-Microphone Usage Description
Select the target project, select Sign&Capabilities > Capability, search for Background Modes and make a double click.
Download the config file GoogleService-Info.plist of firebase, and add it to your project. To get the config file, refer to How to get the config file?.
Set up the URL Types: Fill in the URL Schemes with the REVERSED_CLIENT_ID field in the GoogleService-Info.plist file.
Initialize the ZEGOCallUIKit
To initialize the ZEGOCallUIKit, get the CallManager
instance, pass the AppID of your project.
To receive callbacks, set the corresponding delegate
to self
.
User login
ZEGO Call does not provide user management capabilities yet. You will need to have users log in to Firebase and then call the setLocalUser
method to set user information to CallUIKit based on the login result.
Firebase provides multiple login authentication modes. The following uses Google login as an example.
For more modes, refer to the Firebase official.
Get a Token
ZEGO Call implements the voice and video call feature using the RTC SDK. The caller and called user join the same room and the stream publishing and stream playing start upon the call gets connected. Therefore, to make an outbound call, you will need to provide a token for the RTC SDK for validation. For details, see Use Tokens for authentication.
Before making or accepting an outbound call, you will need to get a Token from the Firebase Cloud Functions.
To set a Token to the token property of the CallManager
, implement the agent-owned callback getRTCToken
of the TokenProvider
.
Make outbound calls
To make an outbound voice call, call the callUser
method and set the type
parameter to CallType.voice
.
To make an outbound video call, call the callUser
method and set the type
parameter to CallType.video
.
After making a call, the CallUIKit shows the UI of the current state automatically for both the callee and caller (integrated the CallUIKit is required), and, you can operate on the UI for further operations.
The following displays when the caller calls the method to make a call (make a voice call for illustration)
The following black pop-up prompts when the callee receives an incoming call (make a voice call for illustration)
Upload logs
When you encounter problems when using your app, call the uploadLog
method to upload logs for us to locate and help you faster.
Deinitialize the ZEGOCallUIKit
After finishing using the ZEGO Call, call the unInit
method to deinitialize the SDK.
Top comments (0)