/ SDKs / Unity
SDKs
Calls SDKs Unity v1
Calls SDKs Unity
Calls SDKs
Unity
Version 1

Make first call

Copy link

Sendbird Calls for Unity enables group calls using real time audio among users within your Sendbird-integrated app. Our development kit can initialize, configure, and build group call functionality in your Unity app.


Requirements

Copy link

The minimum requirements for Calls SDK for Unity are:

  • Unity 2019.4 or higher

Note: Sendbird Calls SDK for Unity supports iOS, Android, Windows, and macOS. The SDK doesn't support 32-bit versions or iOS simulators.


Get started

Copy link

You can start Group call by installing Sendbird Calls for Unity.

Step 1 Install the SDK

Copy link

You can install Calls for Unity by following the steps below:

  1. Select Package Manager in the menu bar.

  2. Click the + button at the top left of the window. Then, select Add package from git URL...

  3. Add SendbirdCalls into your package repository with the following URL: https://github.com/sendbird/sendbird-calls-sdk-unity.git.

  4. Click Add button to start the installation of the package.

  5. Once the package has been added, create a new source code file and add the following code at the top to start using Sendbird Calls SDK.

using Sendbird.Calls;

Step 2 Initialize with APP_ID

Copy link

To integrate and run Sendbird Calls in your application, you need to initialize it first. Initialize the SendBirdCall instance by using the APP_ID of your Sendbird application, which can be found on the Sendbird Dashboard after creating an application. If the instance is initialized with a different APP_ID, all existing call-related data in a client app will be cleared and the SendBirdCall instance will be initialized again with the new APP_ID.

Note: Each Sendbird application can be integrated with a single client app. Within the same application, users can communicate with each other across all platforms, whether they are on mobile devices or on the web.

// Initialize SendBirdCall instance to use APIs in your app.
SendbirdCall.Init(APP_ID);

Step 3 Authenticate a user

Copy link

To start a group call, authenticate a user to Sendbird server by using their user ID through the Authenticate() method.

// The USER_ID below should be unique to your Sendbird application.
SbAuthenticateParams authenticateParams = new SbAuthenticateParams(USER_ID);
SendbirdCall.Authenticate(authenticateParams, (user, error) =>
{
    if( error == null ){/* The user has been authenticated successfully and is connected to Sendbird server. */}
});

Step 4 Create a room

Copy link

To start a group call, you need to create a room, which can support up to 100 participants with audio. You can create a room as shown below and once it has been created, a room ID will be generated.

SbRoomParams roomParams = new SbRoomParams();
SendbirdCall.CreateRoom(roomParams, (room, error) =>
{
    if( error == null ){/* A room is created with a unique identifier room.RoomId. */}
});

Step 5 Enter a room

Copy link

You can now enter a room and start your first group call. When you enter a room, a participant is created with a unique participant ID to represent the user in the room.

To enter a room, you must acquire the room instance from Sendbird server with the room ID. To fetch the most up-to-date room instance from Sendbird server, use the SendbirdCall.FetchRoomById() method. Also, you can use the SendbirdCall.GetCachedRoomById() method that returns the most recently cached room instance from Sendbird Calls SDK.

You can also enter a room by using the room instance that is returned after calling SendbirdCall.CreateRoom().

SendbirdCall.FetchRoomById(ROOM_ID, (room, error) =>
{
    if( error == null ){/* A room with the identifier RoomId is fetched from Sendbird Server. */}
});

SbRoom room = SendbirdCall.GetCachedRoomById(ROOM_ID);
// Returns the most recently cached room with the identifier RoomId from the SDK.
// If there is no such room with the given RoomId, null is returned.

Note: A user can enter the room using multiple devices or browser tabs. Entering from each device or browser tab will create a new participant.

Once the room is retrieved, call the SbRoom.Enter() method to enter the room.

SbRoomEnterParams roomEnterParams = new SbRoomEnterParams();
room.Enter(roomEnterParams, (error) =>
{
    if( error == null ){/* User has successfully entered the room. */}
});

Note: Share the room ID with other users for them to enter the room from the client app.

Step 6 Request permission to access camera and microphone

Copy link

To access camera and microphone when building client app using iOS and macOS, go to PlayerSettings and add Microphone Usage Description. If description is left empty, build fails.