Call Kit
  • iOS : Swift
  • Android
  • Web
  • Flutter
  • React Native
  • Overview
  • Quick start
  • Custom prebuilt UI

Quick start (with call invitation)

Last updated:2022-11-03 14:20

invitation_calls.gif

Integrate the SDK

Prerequisites

  • Go to ZEGOCLOUD Admin Console, and do the following:
    • Create a project, get the AppID and AppSign.
    • Activate the In-app Chat service (as shown in the following figure).
      /Pics/InappChat/ActivateZIMinConsole2.png

Add ZegoUIKitPrebuiltCall as dependencies

  • Open Terminal, navigate to your project's root directory, and run the following to create a podfile:
    pod init
  • Edit the Podfile file to add the basic dependencies:
    pod 'ZegoUIKitPrebuiltCall'
    pod 'ZegoUIKitSignalingPlugin'
  • In Terminal, run the following to download all required dependencies and SDK with Cocoapods:
    pod install

Integrate the call invitation feature

Initialize the call invitation service

Call the init method on the App startup, and specify the userID and userName for connecting the Call Kit service.

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
        // Get your AppID and AppSign from ZEGOCLOUD's Console
        // userID can only contain numbers, letters, and '_'. 
        ZegoUIKitPrebuiltCallInvitationService.shared.initWithAppID(YOUR_APPID, appSign: YOUR_APP_SIGN, userID:YOUR_USER_ID, userName:YOUR_USER_NAME)
    }
}

Add the button for making call invitations

You can customize the position of the ZegoStartCallInvitationButton accordingly, pass in the ID of the user you want to call.

  1. Set up a button for making a voice call.
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // Create Voice Call invitation Button
        let callTargetUser: ZegoUIkitUser = ZegoUIkitUser.init("TargetUserID", "TargetUserName")
        let startVoiceCallButton: ZegoStartCallInvitationButton = ZegoStartCallInvitationButton.init(.voiceCall)
        startVoiceCallButton.text = "voice"
        startVoiceCallButton.setTitleColor(UIColor.blue, for: .normal)
        startVoiceCallButton.inviteeList.append(callTargetUser)
        startVoiceCallButton.frame = CGRect.init(x: 100, y: 100, width: 150, height: 40)
        // Add the button to your view
        self.view.addSubview(startVoiceCallButton)
    }
}
  1. Set up a button for making a video call.
class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // Create Video Call invitation Button
        let callTargetUser: ZegoUIkitUser = ZegoUIkitUser.init("TargetUserID", "TargetUserName")
        let startVideoCallButton: ZegoStartCallInvitationButton = ZegoStartCallInvitationButton.init(.videoCall)
        startVideoCallButton.text = "Video"
        startVideoCallButton.setTitleColor(UIColor.blue, for: .normal)
        startVideoCallButton.inviteeList.append(callTargetUser)
        startVideoCallButton.frame = CGRect.init(x: 100, y: 100, width: 150, height: 40)
        // Add the button to your view.
        self.view.addSubview(startVideoCallButton)
    }
}

Now, you can make call invitations by simply clicking on the buttons you set.

Configure your project

Open the Info.plist, add the following code inside the dict part:

<key>NSCameraUsageDescription</key>
<string>We require camera access to connect to a call</string>
<key>NSMicrophoneUsageDescription</key>
<string>We require microphone access to connect to a call</string>

Run & Test

Now you have finished all the steps!

You can simply click the Run in XCode to run and test your App on your device.

Custom prebuilt UI

Resources