# API Overview Document

The Agora RTM SDK provides a stable messaging mechanism for you to implement real-time messaging scenarios.

This page lists the core APIs of the Agora RTM SDK. Unless otherwise specified, most of the core APIs should only be called after the loginByToken method call succeeds and after you receive the AgoraRtmLoginErrorOk error code.

Following are the core functionalities that the Agora RTM SDK provides.

The connection state between the SDK and the Agora RTM system is a core concept for you to understand before developing an RTM app. For more information, see:

Method Description
initWithAppId Creates and initializes an AgoraRtmKit instance.
loginByToken Logs in the Agora RTM system.
logoutWithCompletion Logs out of the Agora RTM system.
Event Description
connectionStateChanged Occurs when the connection state between the SDK and the Agora RTM system changes.

## Sending a peer-to-peer message

Method Description
initWithText Creates and initializes an AgoraRtmMessage instance.
initWithRawData Creates and initializes an AgoraRtmRawMessage instance.
sendMessage Sends an (offline) peer-to-peer message to a specified user. When used with a prefix, it serves a similar function to the endCall method of the Agora Signaling SDK.
Event Description
messageReceived Occurs when receiving a peer-to-peer message.

## Querying the online status of the specified users

Method Description
queryPeersOnlineStatus Queries the online status of the specified users.

## Subscribing to or unsubscribing from the online status of specified users

Method Description
subscribePeersOnlineStatus Subscribes to the online status of the specified users.
unsubscribePeersOnlineStatus Unsubscribes from the online status of the specified users.
queryPeersBySubscriptionOption Gets a list of the peers, to whose specific status you have subscribed.
Event Description
PeersOnlineStatusChanged Occurs when the online status of the peers, to whom you subscribe, changes.

## User attribute operations

Method Description
setLocalUserAttributes Substitutes the local user’s attributes with new ones.
deleteLocalUserAttributesByKeys Deletes the local user’s attributes using attribute keys. AgoraRtmDeleteLocalUserAttributesBlock returns the result of this method call.
clearLocalUserAttributes Clears all attributes of the local user.
getUserAttributes Gets all attributes of a specified user.
getUserAttributesByKeys Gets the attributes of a specified user by attribute keys.

## Channel attribute operations

Method Description
setChannelAttributes Sets the attributes of a specified channel with new ones.
deleteChannelAttributesByKeys Deletes the attributes of a specified channel by attribute keys.
clearChannelAttributes Clears all attributes of a specified channel.
getChannelAttributes Gets all attributes of a specified channel.
getChannelAttributesByKeys Gets the attributes of a specified channel by attribute keys.
Event for all channel members Description
attributeUpdate Occurs when the channel attributes are updated, and returns all attributes of the channel.

## Retrieving channel member count of specified channels

Method Description
getChannelMemberCount Gets the member count of specified channels.

## Joining or leaving a channel

Method Description
createChannelWithId Creates an AgoraRtmChannel instance.
joinWithCompletion Joins the channel.
leaveWithCompletion Leaves the channel.
destroyChannelWithId Destroys a specified local AgoraRtmChannel instance.
Event Description
memberJoined Occurs when a remote user joins the channel.
memberLeft Occurs when a remote member leaves the channel.
memberCount Occurs when the number of the channel members changes, and returns the new number.

## Channel message

Method Description
initWithText Creates and initializes an AgoraRtmMessage instance.
initWithRawData Creates and initializes an AgoraRtmRawMessage instance.
sendMessage Allows a channel member to send a message to all members in the channel.
Event Description

## Retrieving a member list of the channel

Method Description
getMembersWithCompletion Retrieves a member list of the channel.

## Call invitation management

• API calling sequence for canceling a sent call invitation:

• API calling sequence for accepting a received call invitation:

• API calling sequence for declining a received call invitation:

Method for Managing a Call Manager Description
getRtmCallKit Gets the AgoraRtmCallKit instance.
Caller Method Description
initWithCalleeId Allows the caller to create and initialize an AgoraRtmLocalInvitation object.
sendLocalInvitation Allows the caller to send a call invitation to a remote user.
cancelLocalInvitation Allows the caller to cancel a call invitation.
Callee Method Description
acceptRemoteInvitation Allows the callee to accept a call invitation.
refuseRemoteInvitation Allows the callee to refuse a call invitation.
Caller Event Description
localInvitationReceivedByPeer Callback to the caller: occurs when the callee receives the call invitation.
localInvitationCanceled Callback to the caller: occurs when the caller cancels an outgoing call invitation.
localInvitationAccepted Callback to the caller: occurs when the callee accepts the call invitation.
localInvitationRefused Callback to the caller: occurs when the callee declines the call invitation.
localInvitationFailure Callback to the caller: occurs when the life cycle of an outgoing call invitation ends in failure.
Callee Event Description
remoteInvitationReceived Callback to the callee: occurs when the callee receives a call invitation.
remoteInvitationCanceled Callback to the callee: occurs when the caller cancels the incoming call invitation.
remoteInvitationAccepted Callback to the callee: occurs when the callee accepts a call invitation.
remoteInvitationRefused Callback to the callee: occurs when the callee declines a call invitation.
remoteInvitationFailure Callback to the callee: occurs when the life cycle of the incoming call invitation ends in failure.

## Renew the Token

Method Description
renewToken Renews the RTM Token of the SDK. AgoraRtmRenewTokenBlock returns the result of this method call.
Event Description
rtmKitTokenDidExpire Occurs when the RTM server detects that the RTM token has exceeded the specified validity period.

## Logfile settings and version Check

• Logfile-related operations can be done after creating and initializing the AgoraRtmKit instance and before calling the loginByToken method.
• getSDKVersion is a static method. You can call it before creating and initializing an AgoraRtmKit instance.
Method Description
setLogFile Specifies the default path to the SDK log file.
setLogFileSize Sets the size of a single log file. The SDK has two log files with the same size.
setLogFilters Sets the output log level of the SDK.
getSDKVersion Gets the version of the Agora RTM SDK.

## Customized method

Method Description
‭setParameters Provides the technical preview functionalities or special customizations by configuring the SDK with JSON options.

## Region settings

‭setRtmServiceContext Sets the context of all AgoraRtmKit instances. All AgoraRtmKit instances you create after calling this method match the context.

## Status Codes

### AgoraRtmConnectionState

Connection states between the SDK and the Agora RTM system.

Status code Description
AgoraRtmConnectionStateDisconnected 1: The initial state. The SDK is disconnected from the Agora RTM system.

When the user calls the loginByToken method, the SDK starts to log in the Agora RTM system, triggers the connectionStateChanged callback, and switches to the AgoraRtmConnectionStateConnecting state.

AgoraRtmConnectionStateConnecting 2: The SDK is logging in the Agora RTM system.

• Success: The SDK triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateConnected state.
• Failure: The SDK triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateDisConnected state.
• AgoraRtmConnectionStateConnected 3: The SDK has logged in the Agora RTM system.

• If the connection between the SDK and the Agora RTM system is interrupted because of network issues, the SDK triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateReconnecting state.
• If the login is banned by the server because, for example, another instance logs in the Agora RTM system with the same user ID, the SDK triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateAborted state.
• If the user calls the logoutWithCompletion method to log out of the Agora RTM system and receives AgoraRtmLogoutErrorOk, the SDK triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateDisconnected state.
• AgoraRtmConnectionStateReconnecting 4: The connection state between the SDK and the Agora RTM system is interrupted due to network issues, and the SDK keeps re-logging in the Agora RTM system.

• If the SDK successfully re-logs in the Agora RTM system, it triggers the connectionStateChanged callback and switches to the AgoraRtmConnectionStateConnected state. The SDK automatically adds the user back to the channels he or she was in when the connection was interrupted, and synchronizes the local user’s attributes with the server.
• If the SDK fails to re-log in the Agora RTM system, the SDK stays in the AgoraRtmConnectionStateReconnecting state and keeps re-logging in the system.
• AgoraRtmConnectionStateAborted 5: The SDK gives up logging in the Agora RTM system, mainly because another instance has logged in the Agora RTM system with the same user ID.

You must call the logoutWithCompletion method before calling the loginByToken method to log in the Agora RTM system again.

### AgoraRtmConnectionChangeReason

Reasons for a connection state change.

Status code Description
AgoraRtmConnectionChangeReasonLogin 1: The SDK is logging in the Agora RTM system.
AgoraRtmConnectionChangeReasonLoginSuccess 2: The SDK has logged in the Agora RTM system.
AgoraRtmConnectionChangeReasonLoginFailure 3: The SDK fails to log in the Agora RTM system.
AgoraRtmConnectionChangeReasonLoginTimeout 4: The login has timed out for 10 seconds, and the SDK stops logging in.
AgoraRtmConnectionChangeReasonInterrupted 5: The connection between the SDK and the Agora RTM system is interrupted for more than four seconds.
AgoraRtmConnectionChangeReasonLogout 6: The user has called the logoutWithCompletion method to log out of the Agora RTM system.
AgoraRtmConnectionChangeReasonBannedByServer 7: Login is banned by the Agora RTM server.
AgoraRtmConnectionChangeReasonRemoteLogin 8: Another instance has logged in the Agora RTM system with the same user ID.

### AgoraRtmMessageType

Message types.

Status code Description
AgoraRtmMessageTypeUndefined 0: Undefined message type.
AgoraRtmMessageTypeText 1: A text message.
AgoraRtmMessageTypeRaw 2: A raw message.

### AgoraRtmPeerSubscriptionOptions

Subscription types.

Status code Description
AgoraRtmPeerSubscriptionOnlineStatus 0: Takes out a subscription to the online status of specified users.

### AgoraPeerOnlineState

The online states of a peer.

Status code Description
AgoraRtmPeerOnlineStateOnline 0: The peer is online.
AgoraRtmPeerOnlineStateUnreachable 1: The peer is temporarily unreachable (the server has not received a packet from the SDK for more than 12 seconds).
AgoraRtmPeerOnlineStateOffline 2: The peer is offline (the sdk has not logged in the Agora RTM system, or it has logged out of the system, or the server has not received a packet from the SDK for more than 30 seconds).

### AgoraRtmLocalInvitationState

RETURNED TO THE CALLER. States of an outgoing call invitation.

Status code Description
AgoraRtmLocalInvitationStateIdle 0: RETURNED TO THE CALLER. The initial state of a call invitation (idle).
AgoraRtmLocalInvitationStateSentToRemote 1: FOR INTERNAL USE ONLY.
AgoraRtmLocalInvitationStateReceivedByRemote 2: RETURNED TO THE CALLER. The call invitation is received by the callee.
AgoraRtmLocalInvitationStateAcceptedByRemote 3: RETURNED TO THE CALLER. The call invitation is accepted by the callee.
AgoraRtmLocalInvitationStateRefusedByRemote 4: RETURNED TO THE CALLER. The call invitation is declined by the callee.
AgoraRtmLocalInvitationStateCanceled 5: RETURNED TO THE CALLER. You have canceled the call invitation.
AgoraRtmLocalInvitationStateFailure 6: RETURNED TO THE CALLER. The life cycle of the outgoing call invitation ends in failure.

### AgoraRtmRemoteInvitationState

RETURNED TO THE CALLEE. States of an incoming call invitation.

Status code Description
AgoraRtmRemoteInvitationStateIdle 0: RETURNED TO THE CALLEE. The initial state of a call invitation (idle).
AgoraRtmRemoteInvitationStateInvitationReceived 1: RETURNED TO THE CALLEE. A call invitation from a remote caller is received.
AgoraRtmRemoteInvitationStateAcceptSentToLocal 2: FOR INTERNAL USE ONLY.
AgoraRtmRemoteInvitationStateRefused 3: RETURNED TO THE CALLEE. You have declined the call invitation.
AgoraRtmRemoteInvitationStateAccepted 4: RETURNED TO THE CALLEE. You have accepted the call invitation.
AgoraRtmRemoteInvitationStateCanceled 5: RETURNED TO THE CALLEE. The call invitation is canceled by the remote caller.
AgoraRtmRemoteInvitationStateFailure 6: RETURNED TO THE CALLEE. The life cycle of the incoming call invitation ends in failure.

### AgoraRtmLogFilter

Log Filter types.

Status code Description
AgoraRtmLogFilterOff 0: Do not output any log information.
AgoraRtmLogFilterInfo 0x000f: Output CRITICAL, ERROR, WARNING, and INFO level log information.
AgoraRtmLogFilterWarn 0x000e: Output CRITICAL, ERROR, and WARNING level log information.
AgoraRtmLogFilterError 0x000c: Output CRITICAL and ERROR level log information.
AgoraRtmLogFilterCritical 0x0008: Output CRITICAL level log information.
AgoraRtmLogFilterMask 0x80f: RESERVED FOR FUTURE USE

## Error Codes

### AgoraRtmChannelMemberCountErrorCode

Error codes related to retrieving the channel member count of specified channels.

Error code Description
AgoraRtmChannelMemberCountErrorOk 0: The operation succeeds.
AgoraRtmChannelMemberCountErrorFailure 1: Unknown common failure.
AgoraRtmChannelMemberCountErrorInvalidArgument 2: One or several of your channel IDs is invalid.
AgoraRtmChannelMemberCountErrorTooOften 3: The method call frequency exceeds the limit of one query per second.
AgoraRtmChannelMemberCountErrorTimeout 4: A timeout occurs during this operation. The current timeout is set as five seconds.
AgoraRtmChannelMemberCountErrorExceedLimit 5: The number of the channels that you query is greater than 32.
AgoraRtmChannelMemberCountErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmChannelMemberCountErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before this operation.

### AgoraRtmGetMembersErrorCode

Error codes related to retrieving a channel member list.

Error code Description
AgoraRtmGetMembersErrorOk 0: The user retrieves a member list of the channel successfully.
AgoraRtmGetMembersErrorFailure 1: The user fails to retrieve a member list of the channel.
AgoraRtmGetMembersErrorRejected 2: RESERVED FOR FUTURE USE
AgoraRtmGetMembersErrorTimeout 3: A timeout occurs when retreiving a member list of the channel. The current timeout is set as five seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmGetMembersErrorTooOften 4: The method call frequency exceeds the limit of five queries every two seconds.
AgoraRtmGetMembersErrorNotInChannel 5: The user is not in channel.
AgoraRtmGetMembersErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmGetMembersErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before retrieving a member list.

### AgoraRtmInvitationApiCallErrorCode

Error codes for the call invitation methods.

Error code Description
AgoraRtmInvitationApiCallErrorOk 0: The method call succeeds.
AgoraRtmInvitationApiCallErrorInvalidAugment 1: The method call fails. Invalid argument.
AgoraRtmInvitationApiCallErrorNotStarted 2: The method call fails. The call invitation has not started.
AgoraRtmInvitationApiCallErrorAlreadyEnd 3: The method call fails. The call invitation has ended.
AgoraRtmInvitationApiCallErrorAlreadyAccept 4: The method call fails. The call invitation is already accepted.
AgoraRtmInvitationApiCallErrorAlreadySent 5: The method call fails. The call invitation is already sent.

### AgoraRtmJoinChannelErrorCode

Error codes related to joining a channel.

Error code Description
AgoraRtmJoinChannelErrorOk 0: The user joins the channel successfully.
AgoraRtmJoinChannelErrorFailure 1: The user fails to join the channel.
AgoraRtmJoinChannelErrorRejected 2: RESERVED FOR FUTURE USE
AgoraRtmJoinChannelErrorInvalidArgument 3: The user fails to join the channel because the argument is invalid.
AgoraRtmJoinChannelErrorTimeout 4: A timeout occurs when joining the channel. The current timeout is set as five seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmJoinChannelErrorExceedLimit 5: The number of the RTM channels you are in exceeds the limit of 20.
AgoraRtmJoinChannelErrorAlreadyJoined 6: The user is joining or has joined the channel.
AgoraRtmJoinChannelErrorTooOften 7: The method call frequency exceeds the limit of 50 queries every three seconds.
AgoraRtmJoinSameChannelErrorTooOften 8: The method call frequency exceeds the limit of 2 queries per 5 seconds for the same channel.
AgoraRtmJoinChannelErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmJoinChannelErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before joining the channel.

### AgoraRtmLeaveChannelErrorCode

Error codes related to leaving a channel.

Error code Description
AgoraRtmLeaveChannelErrorOk 0: The user leaves the channel successfully.
AgoraRtmLeaveChannelErrorFailure 1: The user fails to leave the channel.
AgoraRtmLeaveChannelErrorRejected 2: RESERVED FOR FUTURE USE
AgoraRtmLeaveChannelErrorNotInChannel 3: The user is not in the channel.
AgoraRtmLeaveChannelErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmLeaveChannelErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before leaving the channel.

Error code Description
AgoraRtmLoginErrorOk 0: Login succeeds. No error occurs.
AgoraRtmLoginErrorUnknown 1: Login fails for reasons unknown.
AgoraRtmLoginErrorRejected 2: Login is rejected by the server.
AgoraRtmLoginErrorInvalidArgument 3: Invalid login arguments.
AgoraRtmLoginErrorInvalidAppId 4: The App ID is invalid.
AgoraRtmLoginErrorInvalidToken 5: The token is invalid.
AgoraRtmLoginErrorTokenExpired 6: The token has expired, and hence login is rejected.
AgoraRtmLoginErrorNotAuthorized 7: Unauthorized login.
AgoraRtmLoginErrorAlreadyLogin 8: The user has already logged in or is logging in the Agora RTM system, or the user has not called the logoutWithCompletion method to leave the AgoraRtmConnectionStateAborted state.
AgoraRtmLoginErrorTimeout 9: The login times out. The current timeout is set as 12 seconds.
AgoraRtmLoginErrorLoginTooOften 10: The call frequency of the loginByToken method exceeds the limit of two queries per second.
AgoraRtmLoginErrorLoginNotInitialized 101: The SDK is not initialized.

### AgoraRtmLogoutErrorCode

Error codes related to logout.

Error code Description
AgoraRtmLogoutErrorOk 0: Logout succeeds. No error occurs.
AgoraRtmLogoutErrorRejected 1: RESERVED FOR FUTURE USE
AgoraRtmLogoutErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmLogoutErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before the user logs out of the Agora RTM system.

### AgoraRtmPeerSubscriptionStatusErrorCode

Error codes related to subscribing to or unsubscribing from the status of specified peers.

Error code Description
AgoraRtmPeerSubscriptionStatusErrorOk 0: The method call succeeds, or the operation succeeds.
AgoraRtmPeerSubscriptionStatusErrorFailure 1: Common failure. The user fails to subscribe to or unsubscribe from the status of the specified peers.
AgoraRtmPeerSubscriptionStatusErrorInvalidArgument 2: The method call fails. The argument is invalid.
AgoraRtmPeerSubscriptionStatusErrorRejected 3: RESERVED FOR FUTURE USE
AgoraRtmPeerSubscriptionStatusErrorTimeout 4: The SDK fails to receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the \ref agora::rtm::CONNECTION_STATE_ABORTED “CONNECTION_STATE_ABORTED” or \ref agora::rtm::CONNECTION_STATE_RECONNECTING “CONNECTION_STATE_RECONNECTING” state.
AgoraRtmPeerSubscriptionStatusErrorTooOften 5: The method call frequency exceeds the limit of 10 subscribes every five seconds.
PEER_SUBSCRIPTION_STATUS_ERR_OVERFLOW 6: The number of peers, to whom you subscribe, exceeds the limit of 512.
AgoraRtmPeerSubscriptionStatusErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmPeerSubscriptionStatusErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before this operation.

### AgoraRtmProcessAttributeErrorCode

Error codes related to the attrubute operations.

Error code Description
AgoraRtmAttributeOperationErrorOk 0: The attribute operation succeeds.
AgoraRtmAttributeOperationErrorNotReady 1: DEPRECATED
AgoraRtmAttributeOperationErrorFailure 2: The attribute operation fails.
AgoraRtmAttributeOperationErrorInvalidArgument 3: The argument you put for this attribute operation is invalid.
AgoraRtmAttributeOperationErrorSizeOverflow 4: The attribute size exceeds the limit.

• For user attribute operations: The user’s overall attribute size would exceed the limit of 16 KB, one of the user’s attributes would exceeds 8 KB in size, or the number of this user’s attributes would exceed 32 after this attribute operation.
• For channel attribute operations: The channel’s overall attribute size would exceed the limit of 32 KB, one of the channel attributes would exceed 8 KB in size, or the number of this channel’s attributes would exceed 32 after this attribute operation.
• AgoraRtmAttributeOperationErrorTooOften 5: The method call frequency exceeds the limit.

• For setLocalUserAttributes, addOrUpdateLocalUserAttributes, deleteLocalUserAttributesByKeys and clearLocalUserAttributes taken together: the limit is 10 queries every five seconds.
• For getUserAttributes and getUserAttributesByKeys taken together, the limit is 40 queries every five seconds.
• For setChannelAttributes, addOrUpdateChannelAttributes, deleteChannelAttributesByKeys and clearChannelAttributes taken together: the limit is 10 queries every five seconds.
• For getChannelAllAttributes and getChannelAttributesByKeys taken together, the limit is 10 queries every five seconds.
• AgoraRtmAttributeOperationErrorUserNotFound 6: The specified user is not found, either because the user is offline or because the user does not exist.
AgoraRtmAttributeOperationErrorTimeout 7: A timeout occurs in the attribute-related operation. The current timeout is set as five seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmAttributeOperationErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmAttributeOperationErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before the attribute operation.

### AgoraRtmQueryPeersBySubscriptionOptionErrorCode

Error codes related to getting a list of the peers by suscription option type.

Error code Description
AgoraRtmQueryPeersBySubscriptionOptionErrorOk 0: The method call succeeds, or the operation succeeds.
AgoraRtmQueryPeersBySubscriptionOptionErrorFailure 1: Common failure. The user fails to query peers by subscription option type.
AgoraRtmQueryPeersBySubscriptionOptionErrorTimeout 2: The SDK fails to receive a response from the server in 5 seconds. The current timeout is set as 5 seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmQueryPeersBySubscriptionOptionErrorTooOften 3: The method call frequency exceeds the limit of 10 subscribes every five seconds.
AgoraRtmQueryPeersBySubscriptionOptionErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmQueryPeersBySubscriptionOptionErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before this operation.

### AgoraRtmQueryPeersOnlineErrorCode

Error codes related to querying the online status of the specified peers.

Error code Description
AgoraRtmQueryPeersOnlineErrorOk 0: The method call succeeds.
AgoraRtmQueryPeersOnlineErrorFailure 1: The method call fails.
AgoraRtmQueryPeersOnlineErrorInvalidArgument 2: The method call fails. The argument is invalid.
AgoraRtmQueryPeersOnlineErrorRejected 3: RESERVED FOR FUTURE USE
AgoraRtmQueryPeersOnlineErrorTimeout 4: The SDK has not received a response from the server for 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmQueryPeersOnlineErrorTooOften 5: The method call frequency of this method exceeds the limit of 10 queries every five seconds.
AgoraRtmQueryPeersOnlineErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmQueryPeersOnlineErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before querying the online status.

### AgoraRtmLocalInvitationErrorCode

RETURNED TO THE CALLER. Error codes of an outgoing call invitation.

Error code Description
AgoraRtmLocalInvitationErrorOk 0: RETURNED TO THE CALLER. The outgoing call invitation succeeds.
AgoraRtmLocalInvitationErrorRemoteOffline 1: RETURNED TO THE CALLER. The callee is offline.

The SDK:

• Keeps resending the call invitation to the callee, if he or she is offline.
• Returns this error code, if he or she is still offline 30 seconds since the call invitation is sent.
AgoraRtmLocalInvitationErrorRemoteNoResponse 2: RETURNED TO THE CALLER. The callee is online but has not ACKed to the call invitation 30 seconds since it is sent.
AgoraRtmLocalInvitationErrorExpire 3: RETURNED TO THE CALLER. SAVED FOR FUTURE USE. The call invitation expires 60 seconds since it is sent, if the callee ACKs to the call invitation but neither the caller or callee takes any further action (cancel, accpet, or decline it).
AgoraRtmLocalInvitationErrorNotLoggedIn 4: RETURNED TO THE CALLER. The caller is not logged in.

### AgoraRtmRemoteInvitationErrorCode

RETURNED TO THE CALLEE. Error codes of an incoming call invitation.

Error code Description
AgoraRtmRemoteInvitationErrorOk 0: RETURNED TO THE CALLEE. The incoming call invitation succeeds.
AgoraRtmRemoteInvitationErrorLocalOffline 1: RETURNED TO THE CALLEE. The call invitation received by the callee fails: the callee is not online.
AgoraRtmRemoteInvitationErrorAcceptFailure 2: RETURNED TO THE CALLEE. The call invitation received by callee fails: the acceptance of the call invitation fails.
AgoraRtmRemoteInvitationErrorExpire 3: RETURNED TO THE CALLEE. The call invitation received by the callee fails: the call invitation expires 60 seconds since it is sent, if the callee ACKs to the call invitation but neither the caller or callee takes any further action (cancel, accpet, or decline it).

### AgoraRtmRenewTokenErrorCode

Error codes related to renewing the token.

Error code Description
AgoraRtmRenewTokenErrorOk 0: The token-renewing operation succeeds.
AgoraRtmRenewTokenErrorFailure 1: Common unknown failure.
AgoraRtmRenewTokenErrorInvalidArgument 2: The method call fails. The argument is invalid.
AgoraRtmRenewTokenErrorRejected 3: RESERVED FOR FUTURE USE
AgoraRtmRenewTokenErrorTooOften 4: The method call frequency of exceeds the limit of two queries per second.
AgoraRtmRenewTokenErrorTokenExpired 5: The token has expired.
AgoraRtmRenewTokenErrorInvalidToken 6: The token is invalid.
AgoraRtmRenewTokenErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmRenewTokenErrorNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before renewing the token.

### AgoraRtmSendChannelMessageErrorCode

Error codes related to sending a channel message.

Error code Description
AgoraRtmSendChannelMessageErrorOk 0: The server receives the channel message.
AgoraRtmSendChannelMessageErrorFailure 1: The user fails to send the channel message state.
AgoraRtmSendChannelMessageErrorTimeout 2: The SDK does not receive a response from the server in 10 seconds. The current timeout is set as 10 seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmSendChannelMessageTooOften 3: The method call frequency exceeds the limit of 180 calls every three seconds (channel and peer messages taken together).
AgoraRtmSendChannelMessageInvalidMessage 4: The message is null or exceeds 32 KB in length.
AgoraRtmSendChannelMessageErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmSendChannelMessageNotLoggedIn 102: The user does not call the loginByToken method, or the method call of loginByToken does not succeed before sending out a channel message.

### AgoraRtmSendPeerMessageErrorCode

Error codes related to sending a peer-to-peer message.

Error code Description
AgoraRtmSendPeerMessageErrorOk 0: The specified user receives the peer-to-peer message.
AgoraRtmSendPeerMessageErrorFailure 1: The user fails to send the peer-to-peer message.
AgoraRtmSendPeerMessageErrorTimeout 2: A timeout occurs when sending the peer-to-peer message. The current timeout is set as 10 seconds. Possible reasons: The user is in the AgoraRtmConnectionStateAborted or AgoraRtmConnectionStateReconnecting state.
AgoraRtmSendPeerMessageErrorPeerUnreachable 3: The user is offline and has not received the peer-to-peer message.
AgoraRtmSendPeerMessageErrorCachedByServer 4: The specified user is offline and does not receive the peer-to-peer message, but the server has cached the message and will send the message to the specified user when he/she is back online.
AgoraRtmSendPeerMessageErrorTooOften 5: The method call frequency exceeds the limit of 180 calls every three seconds (channel and peer messages taken together).
AgoraRtmSendPeerMessageErrorInvalidUserId 6: The user ID is invalid.
AgoraRtmSendPeerMessageErrorInvalidMessage 7: The message is null or exceeds 32 KB in length.
AgoraRtmSendPeerMessageErrorNotInitialized 101: The SDK is not initialized.
AgoraRtmSendPeerMessageErrorNotLoggedIn 102: The sender does not call the loginByToken method, or the method call of loginByToken does not succeed before sending the peer-to-peer message.