Agora RTC Objective-C API Reference Refactor

Instance Methods | Class Methods | Properties
AgoraLiveKit Class Reference

Inherits <NSObject>.

## Instance Methods
(AgoraRtcEngineKit *_Nonnull) | - getRtcEngineKit
(int) | - joinChannelByToken:channelId:config:uid:
(int) | - leaveChannel
(int) | - renewToken:
(int) | - startPreview:renderMode:
(int) | - stopPreview

## Class Methods
(NSString *_Nonnull) | + getSdkVersion
(instancetype _Nonnull) | + sharedLiveKitWithAppId:
(void) | + destroy

## Properties
_Nullable id< AgoraLiveDelegate > | delegate

## Detailed Description

The base class for managing a live broadcast: Manages the channel and all actions apart from publishing and subscribing.

## Method Documentation

## ◆ getSdkVersion

+ (NSString *_Nonnull) getSdkVersion |  |  |

Returns the version of the Agora SDK.

Returns
  string, SDK version

## ◆ getRtcEngineKit

- (AgoraRtcEngineKit *_Nonnull) getRtcEngineKit |  |  |

Returns the native handler of the SDK engine

## ◆ sharedLiveKitWithAppId:

+ (instancetype _Nonnull) sharedLiveKitWithAppId: |  | (NSString *_Nonnull) | appId |

Initializes the AgoraLiveKit object.

Parameters

  appId | The appId is issued to the application developers by Agora.

Returns
  an object of AgoraLiveKit class

## ◆ destroy

+ (void) destroy |  |  |

Destroys the engine instance.

This method releases all the resources used by the Agora SDK. This is useful for applications that occasionally make voice calls, to free up resources for other operations when not making calls.

Once the application has called destroy to destroy the created RtcEngine instance, no other methods in the SDK can be used and no callbacks occur.

To start communications again, initialize sharedEngineWithappId to establish a new AgoraRtcEngineKit instance.

Note: This method is called synchronously. The result returns after the IRtcEngine object resources are released. The app should not call this interface in the callback generated by the SDK, otherwise the SDK must wait for the callback to return before it can reclaim the related object resources, causing a deadlock.

## ◆ joinChannelByToken:channelId:config:uid:

- (int) joinChannelByToken: |  | (NSString *_Nullable) | token
channelId: |  | (NSString *_Nonnull) | channelId
config: |  | (AgoraLiveChannelConfig *_Nonnull) | channelConfig
uid: |  | (NSUInteger) | uid

Core Methods Allows a user to join a channel.

This method creates an open UDP socket to the AgoraLiveKit cloud service in order to join a channel. Users in the same channel can talk to each other using the same App ID. This method is asynchronous.

Parameters

  token | A Token generated by the app through signature certification.
  channelId | Channel ID. Joining a channel with the same channel ID means that users are joining the same room. The channel ID supported scope: a-z, A-Z, 0-9, space, !#$%&, ()+,-, :;<=., >?@[], ^_, {|}, ~
  config | AgoraLiveChannelConfig
  uid | Optional: ID of each user in the channel that is unique. If it is set as 0, the SDK automatically assigns an ID, which can be found in the [didJoinChannel]([AgoraLiveDelegate liveKit:didJoinChannel:withUid:elapsed:]) delegate.

Returns
  * 0: Success.  * <0: Failure.

## ◆ leaveChannel

- (int) leaveChannel |  |  |

Allows a user to leave a channel, such as hanging up or exiting a call.

Returns
  * 0: Success.  * <0: Failure.

## ◆ renewToken:

- (int) renewToken: |  | (NSString *_Nonnull) | token |

Updates the Token.

The key expires after a certain period of time once the Token scheme is enabled. When the [didOccurError]([AgoraLiveDelegate liveKit:didOccurError:]) callback reports the error ERR_TOKEN_EXPIRED(109), the application should retrieve a new key and then call this method to renew it. Failure to do so will result in the SDK disconnecting from the server.

Parameters

  token | New Token.

Returns
  * 0: Success.  * <0: Failure.

## ◆ startPreview:renderMode:

- (int) startPreview: |  | (VIEW_CLASS *_Nonnull) | view
renderMode: |  | (AgoraVideoRenderMode) | mode

Starts the local video preview.

Before starting the preview, always call the setupLocalVideo:local: method to set up the preview window and configure its attributes and also call the enableVideo method to enable video. If before calling [joinChannelByToken](joinChannelByToken:channelId:info:uid:joinSuccess:) to join the channel, you have called startPreview to start the local video preview, then the local preview will be still in the started state after you called [leaveChannel]([AgoraLiveKit leaveChannel]) to exit the channel. You can call stopPreview to close the local preview.

Parameters

  renderMode | AgoraVideoRenderMode

Returns
  * 0: Success.  * <0: Failure.

## ◆ stopPreview

- (int) stopPreview |  |  |

Stops the local video preview.

Returns
  * 0: Success.  * <0: Failure.

## ◆ sendCustomReportMessage:category:event:label:value:connectionId:

- (int) sendCustomReportMessage: |  | (NSString *_Nullable) | id
category: |  | (NSString *_Nullable) | category
event: |  | (NSString *_Nullable) | event
label: |  | (NSString *_Nullable) | label
value: |  | (NSInteger) | value
connectionId: |  | (NSUInteger) | connectionId

## ◆ setLogLevel:

- (int) setLogLevel: |  | (LogLevel) | level |

## Property Documentation

## ◆ delegate

- (_Nullable id<AgoraLiveDelegate>) delegate
| readwritenonatomicweak

Protocol providing the AgoraLiveKit class with callbacks.