Compile and run a sample project

Updated

Compile and run a project using Agora SDK

Agora provides Open-source sample projects on GitHub to demonstrate the implementation of basic and advanced Video SDK features.

This page shows how to compile, configure, and run the Video SDK React Native sample project.

Prerequisites

  • React Native 0.60 or later. For more information, see Get Started with React Native.
  • Node 16 or later
  • The following, depending onyourtarget platform:
  • A machine running macOS, Windows, or Linux

Project setup

Get the sample project

Run the following command to clone the repository locally:

git clone git@github.com:AgoraIO-Extensions/react-native-agora.git

This repository contains sample projects for Agora Video SDK:

DescriptionPath
Basic functions/example/src/examples/basic
Advanced features/example/src/examples/advanced
Hook example/example/src/examples/hook

Configure the sample project

  1. Install dependencies

    Switch to the root directory and run the following commands to integrate the SDK and install dependencies:

    yarn
  2. Set your App ID and App Token

    Open the /example/src/config/agora.config.ts file and fill in the App ID and temporary token you obtained from the Agora Console.

    // Agora App ID
    let localAppId = '';
    try {
        localAppId = require('./appID').default;
        console.log('appID', localAppId);
    } catch (error) {
        console.warn(error);
    }
    
    const config = {
        appId: localAppId,
        // Agora app token
        token: '',
        // Agora channel ID
        channelId: 'test',
        uid: 0,
        logFilePath: '',
    };
    
    export default config;

Run the sample project

  1. Execute the following command in the project root directory to run the sample project.

    • Target platform Android

      yarn example android
    • Target platform iOS

      yarn example ios
  2. After the operation is complete, the following application appears on your device:

    Showing Android as an example

  3. Select the demo you want to experience from the menu. Choose JoinChannelVideo under Basic as an example, and click join channel.

  4. To test various audio and video interaction use-cases, connect to the Agora web demo, or install and run the sample project on a second device. Make sure you use the same app ID on both devices. When you join the same channel from two devices, you can see and hear each other.