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 RTC SDK features.
This page shows how to compile, configure, and run the RTC 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 on your target platform:
- A machine running macOS, Windows, or Linux
- Java Development Kit (JDK) 11 or later
- Latest version of Android Studio
- A physical or virtual mobile device running Android 5.0 or later
- A machine running macOS
- Xcode 10 or later
- CocoaPods
- A physical or virtual mobile device running iOS 9.0 or later. If you use React Native 0.63 or later, ensure your iOS version is 10.0 or later.
- A machine running macOS, Windows, or Linux
-
A camera and a microphone
-
A valid Agora account and project. Please refer to Agora account management for details.
-
Installed Git
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.gitThis repository contains sample projects for Agora RTC SDK:
| Description | Path |
|---|---|
| Basic functions | /example/src/examples/basic |
| Advanced features | /example/src/examples/advanced |
| Hook example | /example/src/examples/hook |
Configure the sample project
-
Install dependencies
Switch to the root directory and run the following commands to integrate the SDK and install dependencies:
yarn -
Set your App ID and App Token
Open the
/example/src/config/agora.config.tsfile 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
-
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
-
-
After the operation is complete, the following application appears on your device:
Showing Android as an example
-
Select the demo you want to experience from the menu. Choose JoinChannelVideo under Basic as an example, and click join channel.
-
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.
