Options
All
  • Public
  • Public/Protected
  • All
Menu

react-native-agora

The Agora React Native SDK wraps the Agora RTC SDKs for Android and iOS, with which you can quickly implement real-time communication functionality in Android and iOS apps developed using the React Native framework.

  • The RtcEngine class provides the main methods that can be invoked by your application.
  • The RtcEngineEvents class enables callbacks to your application.
  • The RtcChannel class provides methods that enable real-time communications in a specified channel. By creating multiple RtcChannel instances, users can join multiple channels.
  • The RtcChannelEvents class provides callbacks that report events and statistics of a specified channel.

During API calls, the SDK may returns error codes and warning codes. See Error Codes and Warning Codes.

Core methods

Method Description
create Creates an RtcEngine instance.
createWithContext Creates an RtcEngine instance and sets the connection area and log file.
instance Gets a created RtcEngine instance.
destroy Destroys the RtcEngine instance.
setChannelProfile Sets the channel profile of the Agora RtcEngine.
setClientRole Sets the user role and level of the user (LiveBroadcasting profile only).
joinChannel Allows a user to join a channel.
switchChannel Switches to a different channel (LiveBroadcasting profile only).
leaveChannel Allows a user to leave a channel.
renewToken Renews the token.
getConnectionState Gets the connection state of the app.

Core events

Event Description
ConnectionStateChanged Occurs when the network connection state changes.
JoinChannelSuccess Occurs when a user joins a channel.
RejoinChannelSuccess Occurs when a user rejoins a channel.
LeaveChannel Occurs when a user leaves a channel.
ClientRoleChanged Occurs when the user role switches successfully in the interactive live streaming.
ClientRoleChanged Occurs when the user role switch fails in the interactive live streaming.
UserJoined Occurs when a remote user joins a channel.
UserOffline Occurs when a remote user leaves a channel or goes offline.
NetworkTypeChanged Occurs when the network type changes.
ConnectionLost Occurs when the SDK loses connection to the server.
TokenPrivilegeWillExpire Occurs when the token expires in 30 seconds.
RequestToken Occurs when the token expires.

Audio management

Method Description
enableAudio Enables the audio module.
disableAudio Disables the audio module.
setAudioProfile Sets the audio parameters and application scenarios.
adjustRecordingSignalVolume Adjusts the recording volume.
adjustUserPlaybackSignalVolume Adjusts the playback volume of a specified remote user.
adjustPlaybackSignalVolume Adjusts the playback volume of all remote users.
enableLocalAudio Enables/disables the local audio capture.
muteLocalAudioStream Stops/Resumes publishing the local audio stream.
muteRemoteAudioStream Stops/Resumes subscribing to the audio stream of a specified user.
muteAllRemoteAudioStreams Stops/Resumes subscribing to the audio streams of all remote users.

Video management

Method Description
enableVideo Enables the video module.
disableVideo Disables the video module.
setVideoEncoderConfiguration Sets the video encoder configuration.
startPreview Starts the local video preview.
stopPreview Stops the local video preview.
enableLocalVideo Enables/Disables the local video capture.
muteLocalVideoStream Stops/Resumes publishing the local video stream.
muteRemoteVideoStream Stops/Resumes subscribing to the video stream of a specified user.
muteAllRemoteVideoStreams Stops/Resumes subscribing to the video streams of all remote users.

Local media events

Event Description
LocalAudioStateChanged Occurs when the local audio state changes.
LocalVideoStateChanged Occurs when the local video state changes.
FirstLocalAudioFramePublished Occurs when the first audio frame is published.
FirstLocalVideoFramePublished Occurs when the first video frame is published.
FirstLocalVideoFrame Occurs when the first local video frame is rendered.
AudioPublishStateChanged Occurs when the audio publishing state changes.
VideoPublishStateChanged Occurs when the video publishing state changes.

Remote media events

Event Description
RemoteAudioStateChanged Occurs when the remote audio state changes.
RemoteVideoStateChanged Occurs when the remote video state changes.
FirstRemoteVideoFrame Occurs when the first remote video frame is rendered.
AudioSubscribeStateChanged Occurs when the audio subscribing state changes.
VideoSubscribeStateChanged Occurs when the video subscribing state changes.
UserMuteAudio Occurs when a remote user stops/resumes sending the audio stream.
UserMuteVideo Occurs when a remote user stops/resumes sending the video stream.
UserEnableLocalVideo Occurs when a remote user enables/disables the local video capture function.
UserEnableVideo Occurs when a remote user enables/disables the video module.

Statistics events

After joining a channel, SDK triggers this group of callbacks once every two seconds.

Event Description
RtcStats Reports the statistics of RtcEngine.
NetworkQuality Reports the network quality of each user.
LocalAudioStats Reports the statistics of the local audio stream.
LocalVideoStats Reports the statistics of the uploading local video stream.
RemoteAudioStats Reports the statistics of the audio stream from each remote user/host.
RemoteVideoStats Reports the statistics of the video stream from each remote user/host.

Video pre-process and post-process

Method Description
setBeautyEffectOptions Sets the image enhancement options.
enableVirtualBackground Enables/Disables the virtual background. (beta feature)
enableRemoteSuperResolution Enables/Disables the super resolution feature for a remote user's video. (beta feature)
setVideoDenoiserOptions Sets video noise reduction.
setLowLightEnhanceOptions Sets low-light enhancement.
setColorEnhanceOptions Sets color enhancement.
Event Description
VirtualBackgroundSourceEnabled Reports whether the virtual background is successfully enabled. (beta feature)
UserSuperResolutionEnabled Reports whether the super resolution feature is successfully enabled. (beta feature)

Multi-channel management

Method Description
create Initializes and gets an RtcChannel instance. To join multiple channels, create multiple RtcChannel objects.
RtcChannel Provides methods that enable real-time communications in a specified channel.
RtcChannelEvents Provides callbacks that report events and statistics in a specified channel.

Screen capture

Method Description
startScreenCapture Starts screen sharing.
stopScreenCapture Stops screen sharing.
updateScreenCaptureParameters Updates the screen sharing configuration.

Music file playback and mixing

Method Description
startAudioMixing Starts playing and mixing the music file.
stopAudioMixing Stops playing or mixing the music file.
pauseAudioMixing Pauses playing and mixing the music file.
resumeAudioMixing Resumes playing and mixing the music file.
adjustAudioMixingVolume Adjusts the volume of audio mixing.
adjustAudioMixingPlayoutVolume Adjusts the volume of audio mixing for local playback.
adjustAudioMixingPublishVolume Adjusts the volume of audio mixing for remote playback.
setAudioMixingPitch Sets the pitch of the local music file.
getAudioMixingPlayoutVolume Gets the volume of audio mixing for local playback.
getAudioMixingPublishVolume Gets the volume of audio mixing for remote playback.
getAudioMixingDuration Gets the duration (ms) of the music file.
getAudioMixingCurrentPosition Gets the playback position (ms) of the music file.
setAudioMixingPosition Sets the playback starting position (ms) of the music file.
getAudioTrackCount Gets the audio track index of the current music file.
selectAudioTrack Specifies the playback track of the current music file.
setAudioMixingPlaybackSpeed Sets the playback speed of the current music file.
setAudioMixingDualMonoMode Sets the channel mode of the current music file.
Event Description
AudioMixingStateChanged Occurs when the state of the local user's audio mixing file changes.

Audio effect playback

Method Description
getEffectsVolume Gets the volume of the audio effects.
setEffectsVolume Sets the volume of the audio effects.
setVolumeOfEffect Sets the volume of a specified audio effect.
playEffect Plays a specified audio effect.
stopEffect Stops playing a specified audio effect.
stopAllEffects Stops playing all audio effects.
preloadEffect Preloads a specified audio effect file into the memory.
unloadEffect Releases a specified preloaded audio effect from the memory.
pauseEffect Pauses a specified audio effect.
pauseAllEffects Pauses all audio effects.
resumeEffect Resumes playing a specified audio effect.
resumeAllEffects Resumes playing all audio effects.
getEffectDuration Gets the duration of the audio effect file.
getEffectCurrentPosition Gets the playback position of the audio effect file.
setEffectPosition Sets the playback position of an audio effect file.
Event Description
AudioEffectFinished Occurs when the audio effect file playback finishes.

Audio file information

Method Description
getAudioFileInfo Gets the information of a specified audio file.
Event Description
RequestAudioFileInfo Reports the information of an audio file.

Virtual metronome

Method Description
startRhythmPlayer Enables the virtual metronome.
configRhythmPlayer Configures the virtual metronome.
stopRhythmPlayer Disables the virtual metronome.

Voice effect

Method Description
setAudioEffectPreset Sets an SDK preset audio effect.
setVoiceBeautifierPreset Sets an SDK preset voice beautifier effect.
setVoiceBeautifierParameters Sets parameters for SDK preset voice beautifier effects.
setAudioEffectParameters Sets parameters for SDK preset audio effects.
setLocalVoicePitch Sets the voice pitch of the local speaker.
enableLocalVoicePitchCallback Enables reporting the voice pitch of the local user.
setLocalVoiceEqualization Sets the local voice equalization effect.
setLocalVoiceReverb Sets the local voice reverberation.
setVoiceConversionPreset Sets an SDK preset voice conversion effect.
Event Description
LocalVoicePitchInHz Reports the voice pitch of the local user.

Sound localization

Method Description
enableSoundPositionIndication Enables/Disables stereo panning for remote users.
setRemoteVoicePosition Sets the sound position and gain of a remote user.

CDN publisher

This group of methods apply to LiveBroadcasting profile only.

Method Description
startRtmpStreamWithoutTranscoding Starts pushing media streams to a CDN without transcoding.
startRtmpStreamWithTranscoding Starts pushing media streams to a CDN and sets the transcoding configuration.
updateRtmpTranscoding Updates the transcoding configuration.
stopRtmpStream Stops pushing media streams to a CDN.
Event Description
RtmpStreamingStateChanged Occurs when the state of the RTMP or RTMPS streaming changes.
RtmpStreamingEvent Reports events during the RTMP or RTMPS streaming.
TranscodingUpdated Occurs when the publisher's transcoding settings are updated.

Channel Media Relay

Method Description
startChannelMediaRelay Starts to relay media streams across channels.
updateChannelMediaRelay Updates the channels for media stream relay.
pauseAllChannelMediaRelay Pauses the media stream relay to all destination channels.
resumeAllChannelMediaRelay Resumes the media stream relay to all destination channels.
stopChannelMediaRelay Stops the media stream relay.
Event Description
ChannelMediaRelayStateChanged Occurs when the state of the media stream relay changes.
ChannelMediaRelayEvent Reports events during the media stream relay.

Audio volume indication

Method Description
enableAudioVolumeIndication Enables the AudioVolumeIndication callback at a set time interval to report on which users are speaking and the speakers' volume.
Event Description
AudioVolumeIndication Reports which users are speaking and the speakers' volume, and whether the local user is speaking.
ActiveSpeaker Occurs when the most active remote speaker is detected.

Face detection

Method Description
enableFaceDetection Enables/Disables face detection for the local user.
Event Description
FacePositionChanged Reports the face detection result of the local user.

Audio routing control

Method Description
setDefaultAudioRoutetoSpeakerphone Sets the default audio playback route.
setEnableSpeakerphone Enables/Disables the audio playback route to the speakerphone.
isSpeakerphoneEnabled Checks whether the speakerphone is enabled.
Event Description
AudioRouteChanged Occurs when the local audio playback route changes.

In-ear monitoring

Method Description
enableInEarMonitoring Enables in-ear monitoring.
setInEarMonitoringVolume Sets the volume of the in-ear monitor.

Dual video stream mode

Method Description
enableDualStreamMode Enables/disables dual video stream mode.
setRemoteVideoStreamType Sets the video stream type of the remotely subscribed video stream.
setRemoteDefaultVideoStreamType Sets the default video stream type of the remotely subscribed video stream.

Stream fallback

Method Description
setLocalPublishFallbackOption Sets the fallback option for the locally published video stream under unreliable network conditions.
setRemoteSubscribeFallbackOption Sets the fallback option for the remotely subscribed video stream under unreliable network conditions.
setRemoteUserPriority Sets the priority of a remote user's stream.
Event Description
LocalPublishFallbackToAudioOnly Occurs when the locally published video stream falls back to audio only due to poor network conditions or switches back to the video stream after the network conditions improve.
RemoteSubscribeFallbackToAudioOnly Occurs when the remotely subscribed video stream falls back to audio ly due to poor network conditions or switches back to the video stream after the network conditions improve.

Pre-call network test

Method Description
startEchoTest Starts an audio call test.
stopEchoTest Stops the audio call test.
enableLastmileTest Enables the network connection quality test.
disableLastmileTest Disables the network connection quality test.
startLastmileProbeTest Starts the last-mile probe test.
stopLastmileProbeTest Stops the last-mile probe test.
Event Description
LastmileQuality Reports the last-mile network quality of the local user before the user joins a channel.
LastmileProbeResult Reports the last-mile network probe result.

Media metadata

This group of methods apply to LiveBroadcasting profile only.

Method Description
registerMediaMetadataObserver Registers a media metadata observer object.
setMaxMetadataSize Sets the maximum size of the metadata.
sendMetadata Sends the metadata.
unregisterMediaMetadataObserver Unregisters the metadata observer.

Watermark

This group of methods apply to LiveBroadcasting profile only.

Method Description
addVideoWatermark Adds a watermark image to the local video.
clearVideoWatermarks Removes the added watermark image from the video stream.

Video snapshot

Method Description
takeSnapshot Takes a snapshot of a video stream.
Event Description
SnapshotTaken Reports the result of taking a video snapshot.

Encryption

Method Description
enableEncryption Enables/Disables the built-in encryption.

Audio recorder

Method Description
startAudioRecordingWithConfig Starts an audio recording on the client.
stopAudioRecording Stops the audio recording on the client.

Media recorder

Method Description
startRecording Starts recording the local audio and video.
stopRecording Stops recording the local audio and video.
Event Description
RecorderStateChanged Occurs when the recording state changes.
RecorderInfoUpdated Occurs when the recording information is updated.

Camera control

Method Description
switchCamera Switches between front and rear cameras.
isCameraZoomSupported Checks whether the camera zoom function is supported.
isCameraTorchSupported Checks whether the camera flash function is supported.
isCameraFocusSupported Checks whether the camera manual focus function is supported.
isCameraExposurePositionSupported Checks whether the camera exposure function is supported.
isCameraAutoFocusFaceModeSupported Checks whether the camera face auto-focus function is supported.
setCameraZoomFactor Sets the camera zoom ratio.
getCameraMaxZoomFactor Gets the maximum zoom ratio of the camera. (For Android only)
setCameraFocusPositionInPreview Sets the camera manual focus position.
setCameraExposurePosition Sets the camera exposure position.
setCameraTorchOn Enables the camera flash function.
setCameraAutoFocusFaceModeEnabled Enables the camera auto-face focus function.
Event Description
CameraFocusAreaChanged Occurs when the camera focus area changes.
CameraExposureAreaChanged Occurs when the camera exposure area changes.

Stream message

Method Description
createDataStreamWithConfig Creates a data stream.
sendStreamMessage Sends data stream messages.
Event Description
StreamMessage Occurs when the local user receives a remote data stream within five seconds.
StreamMessageError Occurs when the local user fails to receive the remote data stream.

Miscellaneous video control

Method Description
setCameraCapturerConfiguration Sets the camera capturer configuration.

Miscellaneous methods

Method Description
setCloudProxy Sets the Agora cloud proxy service.
enableDeepLearningDenoise Enables or disables deep-learning noise reduction.
getCallId Gets the current call ID.
rate Allows a user to rate a call after the call ends.
complain Allows a user to complain about the call quality after a call ends.
getSdkVersion Gets the SDK version number.
getErrorDescription Retrieves the description of a warning or error code.
addListener Adds the RtcEngineEvents class.
removeListener Removes the specified RtcEngineEvents object.
removeAllListeners Removes all the RtcEngineEvents objects.
setAgoraLibPath Sets the storage directory of `.so` files.

Miscellaneous events

Event Description
Warning Occurs when a warning occurs.
Error Occurs when an error occurs.
ApiCallExecuted Occurs when an API method is executed.
ProxyConnected Reports the proxy connection state.

Generated using TypeDoc