Agora Cloud Recording makes it easy for a developer to record and store the videos from their real-time engagement application. We’ll look at how to add cloud recording to a React Native video chat app. By the end of this tutorial, you’ll be able to record and save video calls from your application to an Amazon S3 bucket for later access.
We’ll be deploying a Golang server to handle requests from our React Native app using the REST API. The Golang server will internally manage calling the Agora Cloud Recording service, which stores the result in an Amazon S3 bucket.
If you haven’t deployed a back-end service or used Golang before, don’t worry. We’ll walk through the entire process together.
Once you’ve created an AWS account, we need to create an Amazon S3 bucket to store our video recordings and an IAM user to access our bucket. If you already have this set up, feel free to skip this section:
S3:PutObject
policy with Programmatic Access.US_EAST_1
region, your bucket number is 0.The back end being used for this project can be found here.
Before deploying our back end, we need the following variables. (It’s time to use our text file.) We’ll be using the Heroku one-click deploy to make it super simple to get our back end up and running. You can use any other service as well:
APP_ID=
APP_CERTIFICATE=
RECORDING_VENDOR=
RECORDING_REGION=
BUCKET_NAME=
BUCKET_ACCESS_KEY=
BUCKET_ACCESS_SECRET=
CUSTOMER_ID=
CUSTOMER_CERTIFICATE=
Note: RECORDING_VENDOR=1 for AWS. Visit this link for more information.
We’ll be using the Agora UIKit for iOS to make the video calling implementation simpler. If you’re new to the Agora UIKit library or the Agora platform, I’d recommend reading through the following blog before getting started:
We’ll start from the branch blog-start
from this repo to get started. This branch has the basic video calling implemented. It just needs the cloud recording and token fetching added in the placeholders.
Make sure you have satisfied the prerequisites for creating and building an iOS app. Git clone or download the ZIP file from the blog-start branch. In the project directory, execute pod install to install the right CocoaPods.
Open ViewController.swift
and enter your back-end URL in the urlBase
property, as well as your Agora App ID. The channel name will be set to "test"
, but it can be any alphanumeric string.
This project uses Agora UIKit for iOS, and we need to add some code for fetching the token using the endpoints used in this specific back end:
Using the same service as the token server, we can start recording using the endpoint /api/start/call
with a POST
call. We also need to store the rid, sid and recUid from the response:
To stop recording, we send a POST
request to the /api/stop/call
endpoint of the back end with the channel
, rid
, sid
, and recUid
in the body:
Let’s create a function to check the status of our recording and log it to the console:
For information on what the status response shows, check out the RESTful API documentation.
That’s it — now you have an app that uses Agora Cloud Recording to store your videos. You can find out how to merge the resulting video fragments here. You can find more information about cloud recording here.
To see and the completed project, clone or download the main branch of the example repository, as well as launching the server.
For more information about building applications using Agora.io SDKs, take a look at the Agora Video Call Quickstart Guide and Agora API Reference.
I also invite you to join the Agora Developer Slack community.