Agora RTC Objective-C API Reference Refactor

Instance Methods
<AgoraRtcEngineDelegate2> Protocol Reference

Inherits <NSObject>, and <AgoraBaseDelegate>.

## Instance Methods
(void) | - rtcEngine:didJoinChannel:withUid:elapsed:
(void) | - rtcEngine:didRejoinChannel:withUid:elapsed:
(void) | - rtcEngine:didJoinedOfUid:elapsed:
(void) | - rtcEngine:didOfflineOfUid:reason:
(void) | - rtcEngine:localAudioStateChanged:error:
(void) | - rtcEngine:firstRemoteAudioFrameDecodedOfUid:elapsed:
(void) | - rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:
(void) | - rtcEngine:didAudioSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:
(void) | - rtcEngine:didAudioPublishStateChange:oldState:newState:elapseSinceLastState:
(void) | - rtcEngine:videoSizeChangedOfSourceType:uid:size:rotation:
(void) | - rtcEngine:localVideoStateChangedOfState:error:sourceType:
(void) | - rtcEngine:remoteVideoStateChangedOfUid:state:reason:elapsed:
(void) | - rtcEngine:remoteUserStateChangedOfUid:state:
(void) | - rtcEngineIntraRequestReceived:
(void) | - rtcEngine:uplinkNetworkInfoUpdate:
(void) | - rtcEngine:downlinkNetworkInfoUpdate:
(void) | - rtcEngine:connectionChangedToState:reason:
(void) | - rtcEngine:wlAccMessage:action:wlAccMsg:
(void) | - rtcEngine:wlAccStats:averageStats:
(void) | - rtcEngine:networkTypeChanged:
(void) | - rtcEngine:permissionError:
(void) | - rtcEngine:channelMediaRelayStateDidChange:error:
(void) | - rtcEngine:didReceiveChannelMediaRelayEvent:
(void) | - rtcEngine:didVideoSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:
(void) | - rtcEngine:didVideoPublishStateChange:sourceType:oldState:newState:elapseSinceLastState:
(void) | - rtcEngine:didLocalVideoTranscoderErrorWithStream:errorCode:
(void) | - rtcEngine:didLocalUserRegisteredWithUserId:userAccount:
(void) | - rtcEngine:didUserInfoUpdatedWithUserId:userInfo:
(void) | - rtcEngineRequestToken:
(void) | - rtcEngineConnectionDidLost:
(void) | - rtcEngine:reportRtcStats:
(void) | - rtcEngine:lastmileProbeTestResult:
(void) | - rtcEngine:uploadLogResultRequestId:success:reason:
(void) | - rtcEngine:didClientRoleChanged:newRole:newRoleOptions:
(void) | - rtcEngine:didClientRoleChangeFailed:currentRole:
(void) | - rtcEngine:didLeaveChannelWithStats:
(void) | - rtcEngine:firstLocalAudioFramePublished:
(void) | - rtcEngine:localAudioStats:
(void) | - rtcEngine:audioMixingStateChanged:reasonCode:
(void) | - rtcEngine:audioMixingPositionChanged:
(void) | - rtcEngine:cameraExposureDidChangedToRect:
(void) | - rtcEngine:firstLocalVideoFramePublishedWithElapsed:sourceType:
(void) | - rtcEngine:firstLocalVideoFrameWithSize:elapsed:sourceType:
(void) | - rtcEngine:localVideoStats:sourceType:
(void) | - rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:
(void) | - rtcEngine:remoteAudioStats:
(void) | - rtcEngine:remoteVideoStats:

## Face Detection Delegate Methods
##
(void) | - rtcEngine:facePositionDidChangeWidth:previewHeight:faces:

## Method Documentation

## ◆ rtcEngine:didJoinChannel:withUid:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didJoinChannel: |  | (NSString *_Nonnull) | channelId
withUid: |  | (NSString *_Nonnull) | userId
elapsed: |  | (NSInteger) | elapsed
| optional

Event of the user joined the channel.

Parameters

  engine | The engine kit
  channelId | The channel name
  userId | The remote user id
  elapsed | The elapsed time (ms) from session beginning

## ◆ rtcEngine:didRejoinChannel:withUid:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didRejoinChannel: |  | (NSString *_Nonnull) | channelId
withUid: |  | (NSString *_Nonnull) | userId
elapsed: |  | (NSInteger) | elapsed
| optional

Event of the user rejoined the channel

Parameters

  engine | The engine kit
  channelId | The channel name
  userId | The user id
  elapsed | The elapsed time (ms) from session beginning

## ◆ rtcEngine:didJoinedOfUid:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didJoinedOfUid: |  | (NSString *_Nonnull) | userId
elapsed: |  | (NSInteger) | elapsed
| optional

Event of remote user joined

Parameters

  engine | The engine kit
  userId | The remote user id
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:didOfflineOfUid:reason:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didOfflineOfUid: |  | (NSString *_Nonnull) | userId
reason: |  | (AgoraUserOfflineReason) | reason
| optional

Event of remote user offlined

Parameters

  engine | The engine kit
  userId | The remote user id
  reason | Reason of user offline, quit, drop or became audience

## ◆ rtcEngine:localAudioStateChanged:error:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
localAudioStateChanged: |  | (AgoraAudioLocalState) | state
error: |  | (AgoraAudioLocalError) | error
| optional

This callback indicates local audio stream state has changed.

Parameters

  engine | The engine kit
  state | Stopped: The initial state Recording: The capturer starts successfully Encoding: The first video frame is successfully encoded Failed: The local video fails to start
  error | OK: The local audio is normal Failure: No specified reason for the local audio failure. DeviceNoPermission: No permission to use the local audio device DeviceBusy: The microphone is in use RecordFailure: The local audio recording fails. Check whether the recording device is working properly EncodeFailure: The local audio encoding fails

## ◆ rtcEngine:firstRemoteAudioFrameDecodedOfUid:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstRemoteAudioFrameDecodedOfUid: |  | (NSString *_Nonnull) | uid
elapsed: |  | (NSInteger) | elapsed
| optional

Occurs when the SDK decodes the first remote audio frame for playback.

Deprecated** . Use `AgoraAudioRemoteStateDecoding(2)` in the [remoteAudioStateChangedOfUid]([AgoraRtcEngineDelegate rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:]) callback instead.

This callback is triggered in either of the following scenarios:

- The remote user joins the channel and sends the audio stream.
- The remote user stops sending the audio stream and re-sends it after 15 seconds. Reasons for such an interruption include:
  - The remote user leaves channel.
  - The remote user drops offline.
  - The remote user calls the [muteLocalAudioStream]([AgoraRtcEngineKit muteLocalAudioStream:]) method to stop sending the local audio stream.
  - The remote user calls the [disableAudio]([AgoraRtcEngineKit disableAudio]) method to disable audio.

Parameters

  engine | AgoraRtcEngineKit object.
  uid | User ID of the remote user sending the audio stream.
  elapsed | The time elapsed (ms) from the local user calling the joinChannel method until the SDK triggers this callback.

## ◆ rtcEngine:remoteAudioStateChangedOfUid:state:reason:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
remoteAudioStateChangedOfUid: |  | (NSString *_Nonnull) | userId
state: |  | (AgoraAudioRemoteState) | state
reason: |  | (AgoraAudioRemoteReason) | reason
elapsed: |  | (NSInteger) | elapsed
| optional

This callback indicates remote audio stream state has changed.

Parameters

  engine | The engine kit
  userId | The user id
  state | Stopped // The remote audio stopped, default state, audio is started or remote user disabled/muted audio stream. Starting // The first remote audio packet is received. Decoding // The remote audio stream is decoded and plays normally. Frozen // The remote audio is frozen. Failed // The remote audio fails to start.
  reason | Interal // Internal reasons. NetworkCongestion // Network congestion. NetworkRecovery // Network recovery. LocalMuted // The local user stops receiving the remote audio stream or disables the audio module. LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module. RemoteMuted // The remote user stops sending the audio stream or disables the audio module. RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module. Offline // The remote user leaves the channel.
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:didAudioSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didAudioSubscribeStateChange: |  | (NSString *_Nonnull) | channelId
uid: |  | (unsigned int) | uid
oldState: |  | (AgoraStreamSubscribeState) | oldState
newState: |  | (AgoraStreamSubscribeState) | newState
elapseSinceLastState: |  | (int) | elapseSinceLastState
| optional

Occurs when the audio subscribe state changed.

Parameters

  channelId | The channel name of user joined.
  uid | The remote user ID that is subscribed to.
  oldState | The old state of the audio stream subscribe : AgoraStreamSubscribeState.
  newState | The new state of the audio stream subscribe : AgoraStreamSubscribeState.
  elapseSinceLastState | The time elapsed (ms) from the old state to the new state.

## ◆ rtcEngine:didAudioPublishStateChange:oldState:newState:elapseSinceLastState:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didAudioPublishStateChange: |  | (NSString *_Nonnull) | channelId
oldState: |  | (AgoraStreamPublishState) | oldState
newState: |  | (AgoraStreamPublishState) | newState
elapseSinceLastState: |  | (int) | elapseSinceLastState
| optional

Occurs when the audio publish state changed.

Parameters

  channelId | The channel name of user joined.
  oldState | The old state of the audio stream publish : AgoraStreamPublishState.
  newState | The new state of the audio stream publish : AgoraStreamPublishState.
  elapseSinceLastState | The time elapsed (ms) from the old state to the new state.

## ◆ rtcEngine:videoSizeChangedOfSourceType:uid:size:rotation:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
videoSizeChangedOfSourceType: |  | (AgoraVideoSourceType) | sourceType
uid: |  | (NSString *_Nonnull) | uid
size: |  | (CGSize) | size
rotation: |  | (NSInteger) | rotation
| optional

Occurs when the local or remote video size or rotation has changed.

Parameters

  engine | AgoraRtcEngineKit object.
  sourceType | The video source type.
  uid | The user ID. 0 indicates the local user.
  size | Size of the video (width and height) in pixels.
  rotation | The rotation information of the video.

## ◆ rtcEngine:contentInspectResult:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
contentInspectResult: |  | (AgoraContentInspectResult) | result
| optional

## ◆ rtcEngine:snapshotTaken:filePath:width:height:errCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
snapshotTaken: |  | (NSUInteger) | uid
filePath: |  | (NSString *_Nonnull) | filePath
width: |  | (NSInteger) | width
height: |  | (NSInteger) | height
errCode: |  | (NSInteger) | errCode
| optional

## ◆ rtcEngine:localVideoStateChangedOfState:error:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
localVideoStateChangedOfState: |  | (AgoraVideoLocalState) | state
error: |  | (AgoraLocalVideoStreamError) | error
sourceType: |  | (AgoraVideoSourceType) | source
| optional

Occurs when the local video stream state changes

This callback indicates the state of the local video stream, including camera capturing and video encoding, and allows you to troubleshoot issues when exceptions occur.

Note
  For some device models, the SDK will not trigger this callback when the state of the local video changes while the local video capturing device is in use, so you have to make your own timeout judgment.

Parameters

  engine | AgoraRtcEngineKit object
  state | State type AgoraVideoLocalState. When the state is AgoraVideoLocalStateFailed (3), see the `error` parameter for details.
  error | The detailed error information: AgoraLocalVideoStreamError.

## ◆ rtcEngine:remoteVideoStateChangedOfUid:state:reason:elapsed:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
remoteVideoStateChangedOfUid: |  | (NSString *_Nonnull) | userId
state: |  | (AgoraVideoRemoteState) | state
reason: |  | (AgoraVideoRemoteReason) | reason
elapsed: |  | (NSInteger) | elapsed
| optional

This callback indicates remote video stream state has changed.

Parameters

  engine | The engine kit
  userId | The user id
  state | Stopped // Default state, video is started or remote user disabled/muted video stream Running // Running state, remote video can be displayed normally Frozen // Remote video is frozen, probably due to network issue.
  reason | Interal // Internal reasons. NetworkCongestion // Network congestion. NetworkRecovery // Network recovery. LocalMuted // The local user stops receiving the remote audio stream or disables the audio module. LocalUnmuted // The local user resumes receiving the remote audio stream or enables the audio module. RemoteMuted // The remote user stops sending the audio stream or disables the audio module. RemoteUnmuted // The remote user resumes sending the audio stream or enables the audio module. Offline // The remote user leaves the channel. AudioFallback //The remote media stream falls back to the audio-only stream due to poor network conditions. AudioFallbackRecovery // The remote media stream switches back to the video stream after the network conditions improve.
  elapsed | The time elapsed (ms) from the local user calling `joinChannel` until this callback is triggered.

## ◆ rtcEngine:remoteUserStateChangedOfUid:state:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
remoteUserStateChangedOfUid: |  | (NSString *_Nonnull) | userId
state: |  | (NSUInteger) | state
| optional

Occurs when the remote user state is updated.

Parameters

  engine | The engine kit
  userId | The remote user id
  state | The remote user state

## ◆ rtcEngine:publishingRequestReceivedFromUid:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
publishingRequestReceivedFromUid: |  | (NSString *_Nonnull) | userId
| optional

## ◆ rtcEngine:publishingRequestAnsweredByOwner:accepted:error:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
publishingRequestAnsweredByOwner: |  | (NSString *_Nonnull) | userId
accepted: |  | (BOOL) | accepted
error: |  | (AgoraErrorCode) | error
| optional

## ◆ rtcEngine:unpublishingRequestReceivedFromOwner:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
unpublishingRequestReceivedFromOwner: |  | (NSString *_Nonnull) | userId
| optional

## ◆ rtcEngineIntraRequestReceived:

- (void) rtcEngineIntraRequestReceived: |  | (AgoraRtcEngineKit *_Nonnull) | engine |
| optional

Intra request received.

Parameters

  engine | The AgoraRtcEngineKit object.

## ◆ rtcEngine:uplinkNetworkInfoUpdate:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
uplinkNetworkInfoUpdate: |  | (AgoraUplinkNetworkInfo *_Nonnull) | bweInfo
| optional

Target bitrate updated.

Parameters

  engine | The AgoraRtcEngineKit object.
  bweInfo | The uplink network info, including target bitrate bps.

## ◆ rtcEngine:downlinkNetworkInfoUpdate:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
downlinkNetworkInfoUpdate: |  | (AgoraDownlinkNetworkInfo *_Nonnull) | networkInfo
| optional

Downlink network info updated.

Parameters

  engine | The AgoraRtcEngineKit object.
  networkInfo | The downlink network info.

## ◆ rtcEngine:connectionChangedToState:reason:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
connectionChangedToState: |  | (AgoraConnectionState) | state
reason: |  | (AgoraConnectionChangedReason) | reason
| optional

Occurs when the connection state of the SDK to the server is changed.

Parameters

  state | See AgoraConnectionState.
  reason | See AgoraConnectionChangedReason.

## ◆ rtcEngine:wlAccMessage:action:wlAccMsg:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
wlAccMessage: |  | (AgoraWlAccReason) | reason
action: |  | (AgoraWlAccAction) | action
wlAccMsg: |  | (NSString *_Nonnull) | wlAccMsg
| optional

Reports WIFI user message. When the user needs to be prompted to approach the AP or switch the frequency band connected to the AP, the SDK will trigger this callback to notify the APP.

Parameters

  engine | AgoraRtcEngineKit object.
  reason | The reason of notifying the user of a message.
  action | Suggest an action for the user.
  wlAccMsg | The message content of notifying the user.

## ◆ rtcEngine:wlAccStats:averageStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
wlAccStats: |  | (AgoraWlAccStats *_Nonnull) | currentStats
averageStats: |  | (AgoraWlAccStats *_Nonnull) | averageStats
| optional

Reports WIFI accelerate status. When the optimized end-to-end delay, frozen ratio and packet loss rate need to be displayed to the user, the SDK will trigger this callback to notify the APP.

Parameters

  engine | AgoraRtcEngineKit object.
  currentStats | Instantaneous value of optimization effect.
  averageStats | Average value of cumulative optimization effect.

## ◆ rtcEngine:networkTypeChanged:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
networkTypeChanged: |  | (AgoraNetworkType) | type
| optional

Occurs when the connection state of the SDK to the server is changed.

Parameters

  engine | The AgoraRtcEngineKit object.
  type | See AgoraNetworkType.

## ◆ rtcEngine:permissionError:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
permissionError: |  | (AgoraPermissionType) | type
| optional

Occurs when permission error

Parameters

  engine | The AgoraRtcEngineKit object.
  type | See AgoraPermissionType.

## ◆ rtcEngine:channelMediaRelayStateDidChange:error:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
channelMediaRelayStateDidChange: |  | (AgoraChannelMediaRelayState) | state
error: |  | (AgoraChannelMediaRelayError) | error
| optional

Occurs when the state of the media stream relay changes.

The SDK reports the state of the current media relay and possible error messages in this callback.

Parameters

  engine | AgoraRtcEngineKit object.
  state | The state code in [AgoraChannelMediaRelayState](AgoraChannelMediaRelayState).
  error | The error code in [AgoraChannelMediaRelayError](AgoraChannelMediaRelayError).

## ◆ rtcEngine:didReceiveChannelMediaRelayEvent:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didReceiveChannelMediaRelayEvent: |  | (AgoraChannelMediaRelayEvent) | event
| optional

Reports events during the media stream relay.

Parameters

  engine | AgoraRtcEngineKit object.
  event | The event code in [AgoraChannelMediaRelayEvent](AgoraChannelMediaRelayEvent).

## ◆ rtcEngine:didVideoSubscribeStateChange:uid:oldState:newState:elapseSinceLastState:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didVideoSubscribeStateChange: |  | (NSString *_Nonnull) | channelId
uid: |  | (unsigned int) | uid
oldState: |  | (AgoraStreamSubscribeState) | oldState
newState: |  | (AgoraStreamSubscribeState) | newState
elapseSinceLastState: |  | (int) | elapseSinceLastState
| optional

Occurs when the video subscribe state changed.

Parameters

  engine | AgoraRtcEngineKit object.
  channelId | The channel name of user joined.
  uid | The remote user ID that is subscribed to.
  oldState | The old state of the video stream subscribe : AgoraStreamSubscribeState.
  newState | The new state of the video stream subscribe : AgoraStreamSubscribeState.
  elapseSinceLastState | The time elapsed (ms) from the old state to the new state.

## ◆ rtcEngine:didVideoPublishStateChange:sourceType:oldState:newState:elapseSinceLastState:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didVideoPublishStateChange: |  | (NSString *_Nonnull) | channelId
sourceType: |  | (AgoraVideoSourceType) | source
oldState: |  | (AgoraStreamPublishState) | oldState
newState: |  | (AgoraStreamPublishState) | newState
elapseSinceLastState: |  | (int) | elapseSinceLastState
| optional

Occurs when the video publish state changed.

Parameters

  engine | AgoraRtcEngineKit object.
  channelId | The channel name of user joined.
  oldState | The old state of the video stream publish : AgoraStreamPublishState.
  newState | The new state of the video stream publish : AgoraStreamPublishState.
  elapseSinceLastState | The time elapsed (ms) from the old state to the new state.

## ◆ rtcEngine:didRhythmPlayerStateChanged:errorCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didRhythmPlayerStateChanged: |  | (AgoraRhythmPlayerState) | state
errorCode: |  | (AgoraRhythmPlayerError) | errorCode
| optional

## ◆ rtcEngine:didLocalVideoTranscoderErrorWithStream:errorCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didLocalVideoTranscoderErrorWithStream: |  | (AgoraTranscodingVideoStream *_Nonnull) | stream
errorCode: |  | (AgoraVideoTranscoderError) | errorCode
| optional

Occurs when local video transcoder stream has error.

Parameters

  stream | Stream type of AgoraTranscodingVideoStream.
  errorCode | Error code of AgoraVideoTranscoderError.

## ◆ rtcEngine:didLocalUserRegisteredWithUserId:userAccount:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didLocalUserRegisteredWithUserId: |  | (NSUInteger) | uid
userAccount: |  | (NSString *_Nonnull) | userAccount
| optionalinherited

Occurs when the local user successfully registers a user account by calling the This callback reports the user ID and user account of the local user.

Parameters

  uid | The ID of the local user.
  userAccount | The user account of the local user.

## ◆ rtcEngine:didUserInfoUpdatedWithUserId:userInfo:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didUserInfoUpdatedWithUserId: |  | (NSUInteger) | uid
userInfo: |  | (AgoraUserInfo *_Nonnull) | userInfo
| optionalinherited

Occurs when the SDK gets the user ID and user account of the remote user.

After a remote user joins the channel, the SDK gets the UID and user account of the remote user, caches them in a mapping table object (`userInfo`), and triggers this callback on the local client.

Parameters

  uid | The ID of the remote user.
  userInfo | The `AgoraUserInfo` object that contains the user ID and user account of the remote user.

## ◆ rtcEngineRequestToken:

- (void) rtcEngineRequestToken: |  | (AgoraRtcEngineKit *_Nonnull) | engine |
| optionalinherited

when token is enabled, and specified token is invalid or expired, this function will be called. APP should generate a new token and call renewToken() to refresh the token. NOTE: to be compatible with previous version, ERR_TOKEN_EXPIRED and ERR_INVALID_TOKEN are also reported via onError() callback. You should move renew of token logic into this callback.

Parameters

  engine | The engine kit

## ◆ rtcEngineConnectionDidLost:

- (void) rtcEngineConnectionDidLost: |  | (AgoraRtcEngineKit *_Nonnull) | engine |
| optionalinherited

Event of loss connection with server. This event is reported after the connection is interrupted and exceed the retry period (10 seconds by default). In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.

Parameters

  engine | The engine kit

## ◆ rtcEngine:reportRtcStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
reportRtcStats: |  | (AgoraChannelStats *_Nonnull) | stats
| optionalinherited

Statistics of rtc engine status. Updated every two seconds.

Parameters

  engine | The engine kit
  stats | The statistics of rtc status, including duration, sent bytes and received bytes

## ◆ rtcEngine:lastmileProbeTestResult:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
lastmileProbeTestResult: |  | (AgoraLastmileProbeResult *_Nonnull) | result
| optionalinherited

Reports the last-mile network probe result.

The SDK triggers this callback within 30 seconds after the app calls the [startLastmileProbeTest]([AgoraRtcEngineKit startLastmileProbeTest:]) method.

Parameters

  engine | AgoraRtcEngineKit object.
  result | The uplink and downlink last-mile network probe test result, see [AgoraLastmileProbeResult](AgoraLastmileProbeResult).

## ◆ rtcEngine:uploadLogResultRequestId:success:reason:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
uploadLogResultRequestId: |  | (NSString *_Nonnull) | requestId
success: |  | (BOOL) | success
reason: |  | (AgoraUploadErrorReason) | reason
| optionalinherited

Reports the user log upload result

Parameters

  requestId | RequestId of the upload
  success | Is upload success
  reason | Reason of the upload, 0: OK, 1 Network Error, 2 Server Error.

## ◆ rtcEngine:didClientRoleChanged:newRole:newRoleOptions:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didClientRoleChanged: |  | (AgoraClientRole) | oldRole
newRole: |  | (AgoraClientRole) | newRole
newRoleOptions: |  | (AgoraClientRoleOptions *_Nullable) | newRoleOptions
| optionalinherited

Event of cient role change. only take effect under broadcasting mode

Parameters

  engine | The engine kit
  oldRole | The previous role of the local user
  newRole | The new role of the local user
  newRoleOptions | The client role options of the current role of the local user

## ◆ rtcEngine:didClientRoleChangeFailed:currentRole:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didClientRoleChangeFailed: |  | (AgoraClientRoleChangeFailedReason) | reason
currentRole: |  | (AgoraClientRole) | currentRole
| optionalinherited

Event of cient role change. only take effect under broadcasting mode

Parameters

  engine | The engine kit
  reason | The reason of the failure of the local user role switches
  currentRole | The current role of the user

## ◆ rtcEngine:didLeaveChannelWithStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
didLeaveChannelWithStats: |  | (AgoraChannelStats *_Nonnull) | stats
| optionalinherited

The statistics of the call when leave channel

Parameters

  engine | The engine kit
  stats | The statistics of the call, including duration, sent bytes and received bytes

## ◆ rtcEngine:firstLocalAudioFramePublished:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstLocalAudioFramePublished: |  | (NSInteger) | elapsed
| optionalinherited

Event of the first audio frame is sent.

Parameters

  engine | The engine kit
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:localAudioStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
localAudioStats: |  | (AgoraRtcLocalAudioStats *_Nonnull) | stats
| optionalinherited

The statistics of the local audio stream.

Same as [localAudioStatBlock]([AgoraRtcEngineKit localAudioStatBlock:]). The SDK updates the application on the statistics of the local audio stream once every two seconds.

Parameters

  engine | The AgoraRtcEngineKit object.
  stats | AgoraRtcLocalAudioStats

## ◆ rtcEngine:audioMixingStateChanged:reasonCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
audioMixingStateChanged: |  | (AgoraAudioMixingStateType) | state
reasonCode: |  | (AgoraAudioMixingReasonCode) | reasonCode
| optionalinherited

Audio mixing state changed.

Parameters

  engine | The AgoraRtcEngineKit object.
  state | AgoraAudioMixingStateType
  reasonCode | AgoraAudioMixingReasonType

## ◆ rtcEngine:audioMixingPositionChanged:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
audioMixingPositionChanged: |  | (NSInteger) | position
| optionalinherited

Reports current AudioMixing progress.

The callback occurs once every one second during the playback and reports the current playback progress.

Parameters

  position | Current AudioMixing progress (millisecond).

## ◆ rtcEngine:cameraExposureDidChangedToRect:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
cameraExposureDidChangedToRect: |  | (CGRect) | rect
| optionalinherited

A camera exposure position changed.

Parameters

  engine | AgoraRtcEngineKit object
  rect | Exposure rectangle in the local preview

## ◆ rtcEngine:firstLocalVideoFramePublishedWithElapsed:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstLocalVideoFramePublishedWithElapsed: |  | (NSInteger) | elapsed
sourceType: |  | (AgoraVideoSourceType) | source
| optionalinherited

Event of the first local video frame is published.

Parameters

  engine | The engine kit
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:firstLocalVideoFrameWithSize:elapsed:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
firstLocalVideoFrameWithSize: |  | (CGSize) | size
elapsed: |  | (NSInteger) | elapsed
sourceType: |  | (AgoraVideoSourceType) | source
| optionalinherited

Event of the first local frame starts rendering on the screen.

Parameters

  engine | The engine kit
  size | The size of local video stream
  elapsed | The elapsed time(ms) from the beginning of the session.

## ◆ rtcEngine:localVideoStats:sourceType:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
localVideoStats: |  | (AgoraRtcLocalVideoStats *_Nonnull) | stats
sourceType: |  | (AgoraVideoSourceType) | source
| optionalinherited

The statistics of local video stream. Update every two seconds.

Parameters

  engine | The engine kit
  stats | The statistics of local video, including sent bitrate, sent framerate

## ◆ rtcEngine:reportAudioVolumeIndicationOfSpeakers:totalVolume:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
reportAudioVolumeIndicationOfSpeakers: |  | (NSArray< AgoraRtcAudioVolumeInfo * > *_Nonnull) | speakers
totalVolume: |  | (NSInteger) | totalVolume
| optionalinherited

The sdk reports the volume of a speaker. The interface is disable by default, and it could be enable by API "enableAudioVolumeIndication"

Parameters

  engine | The engine kit
  speakers | AgoraRtcAudioVolumeInfo array
  totalVolume | The total volume of speakers

## ◆ rtcEngine:remoteAudioStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
remoteAudioStats: |  | (AgoraRtcRemoteAudioStats *_Nonnull) | stats
| optionalinherited

The statistics of remote audio stream. Update every two seconds.

Parameters

  engine | The engine kit
  stats | The statistics of audio video, including user id, delay, resolution, received bitrate, received framerate, audio stream type

## ◆ rtcEngine:remoteVideoStats:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
remoteVideoStats: |  | (AgoraRtcRemoteVideoStats *_Nonnull) | stats
| optionalinherited

The statistics of remote video stream. Update every two seconds.

Parameters

  engine | The engine kit
  stats | The statistics of remote video, including user id, delay, resolution, received bitrate, received framerate, video stream type

## ◆ rtcEngine:rtmpStreamingChangedToState:state:errCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
rtmpStreamingChangedToState: |  | (NSString *_Nonnull) | url
state: |  | (AgoraRtmpStreamingState) | state
errCode: |  | (AgoraRtmpStreamingErrorCode) | errCode
| optionalinherited

## ◆ rtcEngine:rtmpStreamingEventWithUrl:eventCode:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
rtmpStreamingEventWithUrl: |  | (NSString *_Nonnull) | url
eventCode: |  | (AgoraRtmpStreamingEvent) | eventCode
| optionalinherited

## ◆ rtcEngine:facePositionDidChangeWidth:previewHeight:faces:

- (void) rtcEngine: |  | (AgoraRtcEngineKit *_Nonnull) | engine
facePositionDidChangeWidth: |  | (int) | width
previewHeight: |  | (int) | height
faces: |  | (NSArray< AgoraFacePositionInfo * > *_Nullable) | faces

Reports the face detection result of the local user. (iOS only)

Since:** v3.0.1.

Once you enable face detection by calling [enableFaceDetection]([AgoraRtcEngineKit enableFaceDetection:]), you can get the following information on the local user in real-time:

- The width and height of the local video.
- The position of the human face in the local video.

- The distance between the human face and the device screen. This value is based on the fitting calculation of the local video size and the position of the human face.

  Note**

- If the SDK does not detect a face, it reduces the frequency of this callback to reduce power consumption on the local device.
- The SDK stops triggering this callback when a human face is in close proximity to the screen.

Parameters

  engine | AgoraRtcEngineKit object.
  width | The width (px) of the local video.
  height | The height (px) of the local video.
  faces | An AgoraFacePositionInfo array, which contains the information of the detected human face.

The number of the AgoraFacePositionInfo array depends on the number of human faces detected. If the array length is 0, it means that no human face is detected.