Agora RTC Objective-C API Reference  Refactor
Instance Methods | Class Methods
AgoraRtmClientKit Class Reference

Inherits <NSObject>.

Instance Methods

(instancetype _Nullable) - initWithConfig:delegate:error:
 
(void) - loginByToken:completion:
 
(void) - logout:
 
(AgoraRtmStorage *_Nullable) - getStorage
 
(AgoraRtmLock *_Nullable) - getLock
 
(AgoraRtmPresence *_Nullable) - getPresence
 
(void) - renewToken:completion:
 
(void) - subscribeWithChannel:option:completion:
 
(void) - unsubscribeWithChannel:completion:
 
(void) - publish:message:option:completion:
 
(void) - publish:data:option:completion:
 
(void) - addDelegate:
 
(void) - removeDelegate:
 
(AgoraRtmStreamChannel *_Nullable) - createStreamChannel:error:
 
(AgoraRtmErrorCode- destroy
 

Class Methods

(NSString *_Nullable) + getErrorReason:
 
(NSString *_Nonnull) + getVersion
 

Detailed Description

The AgoraRtmClientKit class.

This class provides the main methods that can be invoked by your app.

AgoraRtmClientKit is the basic interface class of the Agora RTM SDK. Creating an AgoraRtmClientKit object and then calling the methods of this object enables you to use Agora RTM SDK's functional

Method Documentation

◆ NS_UNAVAILABLE

- (instancetype _Nullable) NS_UNAVAILABLE

◆ initWithConfig:delegate:error:

- (instancetype _Nullable) initWithConfig: (AgoraRtmClientConfig *_Nonnull)  config
delegate: (id< AgoraRtmClientDelegate > _Nullable)  delegate
error: (NSError **)  error 

Initializes the rtm client instance.

Parameters
configThe configurations for RTM Client.
delegateThe callbacks handler.
errorWhen get nil instance, get error info from error.
Returns
  • nil: initialize rtm client failed, and the error information can be retrievd via the error parameter.
  • not nil: initialize rtm client success.

◆ loginByToken:completion:

- (void) loginByToken: (NSString *_Nullable)  token
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Login the Agora RTM service. The operation result will be notified by agora::rtm::IRtmEventHandler::onLoginResult callback.

Parameters
tokenToken used to login RTM service.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ logout:

- (void) logout: (AgoraRtmOperationBlock _Nullable)  completionBlock

Logout the Agora RTM service. Be noticed that this method will break the rtm service includeing storage/lock/presence.

Parameters
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ getStorage

- (AgoraRtmStorage* _Nullable) getStorage

Get the storage instance.

Returns
  • return nil if error occured

◆ getLock

- (AgoraRtmLock* _Nullable) getLock

Get the lock instance.

Returns
  • return nil if error occured

◆ getPresence

- (AgoraRtmPresence* _Nullable) getPresence

Get the presence instance.

Returns
  • return nil if error occured

◆ renewToken:completion:

- (void) renewToken: (NSString *_Nonnull)  token
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Renews the token. Once a token is enabled and used, it expires after a certain period of time. You should generate a new token on your server, call this method to renew it.

Parameters
tokenToken used renew.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ subscribeWithChannel:option:completion:

- (void) subscribeWithChannel: (NSString *_Nonnull)  channelName
option: (AgoraRtmSubscribeOptions *_Nullable)  subscribeOption
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Subscribe a channel.

Parameters
channelNameThe name of the channel.
subscribeOptionThe options of subscribe the channel.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ unsubscribeWithChannel:completion:

- (void) unsubscribeWithChannel: (NSString *_Nonnull)  channelName
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Unsubscribe a channel.

Parameters
channelNameThe name of the channel.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ publish:message:option:completion:

- (void) publish: (NSString *_Nonnull)  channelName
message: (NSString *_Nonnull)  message
option: (AgoraRtmPublishOptions *_Nullable)  publishOption
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Publish a message in the channel.

Parameters
channelNameThe name of the channel.
messageThe content of the string message.
publishOptionThe option of the message.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ publish:data:option:completion:

- (void) publish: (NSString *_Nonnull)  channelName
data: (NSData *_Nonnull)  data
option: (AgoraRtmPublishOptions *_Nullable)  publishOption
completion: (AgoraRtmOperationBlock _Nullable)  completionBlock 

Publish a message in the channel.

Parameters
channelNameThe name of the channel.
dataThe content of the raw message.
publishOptionThe option of the message.
completionBlockThe operation result will be notified by completionBlock, if operation success,will given a not nil response and nil errorInfo,if operation failed,will given a nil response and not nil errorInfo.

◆ addDelegate:

- (void) addDelegate: (id< AgoraRtmClientDelegate > _Nonnull)  delegate

add more delegate instance.

Parameters
delegateThe name of the channel.

◆ removeDelegate:

- (void) removeDelegate: (id< AgoraRtmClientDelegate > _Nonnull)  delegate

remove delegate instance.

Parameters
delegateThe name of the channel.

◆ getErrorReason:

+ (NSString* _Nullable) getErrorReason: (AgoraRtmErrorCode errorCode

Convert error code to error string.

Parameters
errorCodeReceived error code
Returns
The error reason

◆ getVersion

+ (NSString * _Nonnull) getVersion

Get the version info of the AgoraRtmKit.

Returns
The version info of the AgoraRtmKit.

◆ createStreamChannel:error:

- (AgoraRtmStreamChannel * _Nullable) createStreamChannel: (NSString *_Nonnull)  channelName
error: (NSError **)  error 

create a stream channel instance.

Parameters
channelNameThe Name of the channel.
errorWhen get nil instance, get error info from error.
Returns
  • nil: create stream channel failed,and the error information can be retrievd via the error parameter.
  • not nil: create stream channel success.

◆ destroy

- (AgoraRtmErrorCode) destroy

destroy the rtm client instance.

Returns
  • AgoraRtmErrorOk: Success.
  • other: Failure.