Agora RTC Objective-C API Reference Refactor

Public Member Functions
IRtmService Class Referenceabstract

## Public Member Functions
virtual int | initialize (const char *appId, IRtmServiceEventHandler *eventHandler)=0
virtual void | unregisterObserver (IRtmServiceEventHandler *eventHandler)=0
virtual int | release (bool sync=false)=0
virtual int | login (const char *token, const char *userId)=0
virtual int | logout ()=0
virtual int | sendMessageToPeer (const char *peerId, const IMessage *message)=0
virtual IChannel * | createChannel (const char *channelId, IChannelEventHandler *eventHandler)=0

## Detailed Description

The IRtmService class.

## Constructor & Destructor Documentation

## ◆ ~IRtmService()

virtual ~IRtmService | ( |  | ) |
| inlinevirtual

## Member Function Documentation

## ◆ initialize()

virtual int initialize | ( | const char * | appId,
|  | IRtmServiceEventHandler * | eventHandler
| ) |  |
| pure virtual

Creates and gets an IRtmService instance.

Parameters

  appId | The pointer to the app ID.
  eventHandler | The pointer to the IRtmServiceEventHandler object.
  eventSpace | The connection specific ID, used during report to argus.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ unregisterObserver()

virtual void unregisterObserver | ( | IRtmServiceEventHandler * | eventHandler | ) |
| pure virtual

Releases the IRtmServiceEventHandler object.

Parameters

  eventHandler | The pointer to the IRtmServiceEventHandler object.

## ◆ release()

virtual int release | ( | bool | sync = `false` | ) |
| pure virtual

Releases the IRtmService instance.

Parameters

  sync | Determines whether to report the result of this method call synchronously. true: Report the result of this method call after the IRtmService instance is released. false: (Default) Report the result of this method call immediately, even when the IRtmService is not released.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ login()

virtual int login | ( | const char * | token,
|  | const char * | userId
| ) |  |
| pure virtual

Logs in the RTM service.

Note
  - If you login with the same user ID from a different instance, your previous login will be kicked.
  - The call frequency limit of this method is 2 queries per second.

Parameters

  token | The token used to log in the RTM service.
  userId | ID of the user logging in the RTM service.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ logout()

virtual int logout | ( |  | ) |
| pure virtual

Logs out of the RTM service.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ sendMessageToPeer()

virtual int sendMessageToPeer | ( | const char * | peerId,
|  | const IMessage * | message
| ) |  |
| pure virtual

Sends a peer message to a specified remote user.

Parameters

  peerId | The pointer to the ID of the remote user.
  message | The pointer to message: IMessage.

Returns
  - 0: Success.
  - < 0: Failure.

## ◆ createChannel()

virtual IChannel* createChannel | ( | const char * | channelId,
|  | IChannelEventHandler * | eventHandler
| ) |  |
| pure virtual

Creates an RTM channel.

Parameters

  channelId | The unique channel name for an RTM session. Supported character scopes are: All lowercase English letters: a to z. All uppercase English letters: A to Z. All numeric characters: 0 to 9. The space character. Punctuation characters and other symbols, including: "!", "#", "$", "%", "&", "(", ")", "+", "-", ":", ";", "<", "=", ".", ">", "?", "@", "[", "]", "^", "_", " {", "}", "|", "~", ","
  eventHandler | The pointer to IChannelEventHandler.

Returns
  - The pointer to an IChannel instance, if the method call succeeds.
  - An empty pointer NULL, if the method call fails.