(iOS) Run Video Chat within your Unity application 📱🎮

Sid Sharma
Agora.io
Published in
4 min readMar 6, 2019

When playing games with your friends, the real fun comes when you can trash-talk and gloat on how good you are! Whether you are playing a first-person shooter or playing a game of poker, you want to be able to communicate with your team or see the competitors’ reactions to see if they are bluffing. More mobile games are adding real-time communication within their app to increase user stickiness and user engagement.

The Agora Video SDK for Unity enables you to add in-game real-time communications to increase interactivity between players with minimum impact on the gameplay.

A sample app is included in the Unity Asset and demonstrates the basic Agora SDK features:

  • Join a Channel
  • Leave a Channel
  • Video Chat with multiple participants

This blog post will enable you to run the sample app on an iOS device within a few minutes.

Prerequisites

- Agora.io Developer Account

- Unity 3D 5.5+

Get an Agora Developer Account & App ID

To build and run the sample application you must obtain an App ID:

1. Create a developer account at agora.io. Once you finish the signup process, you will be redirected to the Dashboard.

2. Navigate in the Dashboard tree on the left to Projects > Project List.

3. Copy the App ID that you obtained from the Dashboard into a text file. You will use this when you launch the app.

Set up the Demo Application

1. Add Agora Video SDK for Unity to your assets from the Unity Asset Store.

Note: If you see a Terms of Service page, click Accept to add the project.
Once the project has been added, a confirmation message will appear at the top of the screen.

2. Click Open in Unity to launch Unity.

3. When Unity opens, click New to start a new project.

4. Click Create project to create a new project.

5. Once your project is created, ensure the Asset Store tab is selected. If the Agora Video project is not already loaded, search for Agora in the search box.

Find the Agora Video SDK for Unity project. Click the project box to open the project details.

6. Scroll down and click Download.

Note: The button changes to a loading bar to show download progress.

7. When the download is complete, the Import button will appear. Click Import to load Agora Video into your project.

Add Your AppID

Great! Now that we have the plugin downloaded and imported to our project we need to add our App ID before we can build and run our app. Log into your Agora.io developer account and create a new App ID or select an existing one.

Open SceneHome from the project’s assets.

Next select the GameController from the scene’s hierarchy. You’ll notice that the GameController GameObject has a property App ID, this is where we’ll add our Agora App ID.

Running the Sample Application

Open the Build Settings and add the Unity scenes to the compilation and select the compilation platform (iOS)

  1. Change the Bundle Identifier to your own Bundle identifier so XCode can properly codesign the application.
  2. Ensure the microphone permission has a description to allow the user to know why the microphone is being accessed by the application
  3. Ensure the camera permission has a description to allow the user to know why the camera is being accessed by the application

6. Once all the setup is complete click Build and Run. Once XCode opens up, enable auto-signing (or sign the project) and run the sample application on your iOS test device. Note: The sample app will not run in the simulator as there is no way to access the camera and microphone on a simulator.

Other Resources

--

--

Sid Sharma
Agora.io

Born and raised in the Bay Area #Cali ☀️ I speak Swift & C#. Sometimes English. GS Warriors | Dallas Cowboys | Chi Cubs DevRel | @Nexmo | @CodinGame | @Agora.io