logo
On this page

Quick start


Prerequisites

Integrate the SDK

Import the SDK

Choose either of the following to import the Call Kit:

Initialize the Call Kit with call invitation feature

Initialize the Call Kit, and add the call invitation plug-in:

  • Generate a Kit Token
  • Fill in the required parameters in the following code.
// Generate a Token by calling a method.
// @param 1: appID
// @param 2: serverSecret
// @param 3: Room ID
// @param 4: User ID
// @param 5: Username
const userID = ""; 
const userName = "userName" + userID;
const appID = 0;
const serverSecret = "";
const TOKEN = ZegoUIKitPrebuilt.generateKitTokenForTest(appID, serverSecret,null, userID, userName);

const zp = ZegoUIKitPrebuilt.create(TOKEN);
zp.addPlugins({ ZIM });

Set a button-trigger event

Set up a button and add a button-click event for making call invitations.

You can customize the position of the button you set for making call invitations accordingly, passing in the ID of the user you want to call.

  <button onclick="invite()">invite</button>
function invite() {
   const targetUser = {
        userID:'',
        userName:''
    };
   zp.sendCallInvitation({
    callees: [targetUser],
    callType: ZegoUIKitPrebuilt.InvitationTypeVideoCall,
    timeout: 60, // Timeout duration (second). 60s by default, range from [1-600s].
   }).then((res) => {
    console.warn(res);
   })
   .catch((err) => {
   console.warn(err);
   });
}

Run & Test

So far, you have finished all the steps!

Now you can start up and run the project in a browser using a server you're familiar with.

Resources

Reference

  • Description

    Send a call invitation.

  • Function Prototype

    sendCallInvitation(params: {
        callees: ZegoUser[];
        callType: ZegoInvitationType;
        timeout?: number;
        roomID?: string;      
        data?: string;
        notificationConfig?: ZegoSignalingPluginNotificationConfig;
    }): Promise<{
        errorInvitees: ZegoUser[];
    }>;
  • Parameter Description

    ParameterTypeRequiredDescription
    calleesZegoUser[]YesList of callee users. A user can invite up to 9 other users at most.
    callTypeZegoInvitationTypeYesCall type.
    timeoutnumberNoThe duration of waiting for the callee response to the invitation, in seconds, with a value range of [1, 600]. The default value is 90.
    roomIDstringNoRoom ID, generated by you, is a string with a maximum length of 128 bytes. It only supports numbers, English characters, and the following characters: '~', '!', '@', '#', '$', '', '^', '&', '*', '(', ')', '_', '+', '=', '-', ', ';', '’', ',', '.', '<', '>', '/'.
    datastringNoExtension field.
    notificationConfigZegoSignalingPluginNotificationConfigNoOffline push configuration.
  • Description

    User information class.

  • Parameter Description

    ParameterTypeRequiredDescription
    userIDstringYesUnique identifier of the user, defined by you, up to 32 bytes long, only supporting numbers, English characters, and '!', '#', '$', '&', '(', ')', '+', '-', ':', ';', '<', '=', '.', '>', '?', '@', '[', ']', '^', '_', '{', '}', '
    userNamestringNoName of the user. Up to 256 bytes long.
    avatarstringNoSet the user avatar on the call page.
    setUserAvatar(avatar: string) => voidNoMethod to set the user avatar by passing in the image resource address.
  • Description

    Enumeration class of call invitation types.

  • Enumerations

    EnumValueDescription
    VoiceCall0Voice call.
    VideoCall1Video call.
  • Description

    Offline invitation configuration.

  • Parameter Description

    ParameterTypeRequiredDescription
    resourcesIDstringNoAn English string that can map multiple vendor advanced push configurations, with a length not exceeding 32 characters, customized by the developer. which must be set to the same value as the Push Resource ID in ZEGOCLOUD Admin Console.
    titlestringNoPush title.
    messagestringNoContent of the push.

Previous

Authentication and Kit Token

Next

Customize the UI for call invitation