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 login method call succeeds and after you receive the onSuccess callback.

Following are the core functionalities that the Agora RTM SDK.

Login & Logout

Method Description
createInstance Creates and returns an RtmClient instance.
login Logs in the Agora RTM system.
  • Success: The local user receives the onSuccess callback.
  • Failure: The local user receives the onFailure callback. See LoginError for the error codes.
logout Logs out of the Agora RTM system.
  • Success: The local user receives the onSuccess callback.
  • Failure: The local user receives the onFailure callback. See LogoutError for the error codes.
release Releases all resources used by the RtmClient instance.
Event Description
onConnectionStateChanged Occurs when the connection state changes between the SDK and the Agora RTM system.

Sending a peer-to-peer message

Method Description
createMessage Creates and returns an RtmMessage instance.
sendMessageToPeer Sends an (offline) peer-to-peer message to a specified user. See SendMessageOptions for the offline messaging settings.
Event Description
RtmClientListener.onMessageReceived 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 user(s).

User attribute-related operations

Method Description
setLocalUserAttributes Substitutes the local user's attributes with new ones.
addOrUpdateLocalUserAttributes Adds or updates the local user's attribute(s).
deleteLocalUserAttributesByKeys Deletes the local user's attributes using attribute keys.
clearLocalUserAttributes Clears all attributes of the local user.
getUserAttributes Gets all attributes of a specified user.
getUserAttributesByKeys Gets the attributes of a specified user using attribute keys.

Joining or leaving a channel

Method Description
createChannel Creates an RtmChannel instance.
  • Success: Returns an RtmChannel instance.
  • Failure: Returns null.
join Joins a channel.
leave Leaves a channel.
getId Retrieves the channel ID.
release Releases all resources used by the current channel.
Event Description
onMemberJoined Occurs when a remote user joins the channel.
onMemberLeft Occurs when a remote channel member leaves the channel.

Channel message

Method Description
createMessage Creates and returns an RtmMessage instance.
sendMessage Allows a channel member to send a message to all members in the channel.
Event Description
RtmChannelListener.onMessageReceived Occurs when receiving a channel message.

Retrieving the member list of a channel

Method Description
getMembers Retrieves the member list of a channel.
  • Success: The local user receives the onSuccess callback and the member list of the channel.
  • Failure: The local user receives the onFailure callback. See GetMembersError for the error codes.

Call invitation management

Method Description
getRtmCallManager Gets an Agora RTM call manager.
setEventListener Sets the event listener of an RtmCallManager instance.
createLocalInvitation Allows the caller to create and manage a LocalInvitation object.
sendLocalInvitation Allows the caller to send a call invitation to a remote user.
cancelLocalInvitation Allows the caller to cancel a sent call invitation.
acceptRemoteinvitation Allows the callee to accept a received call invitation.
refuseRemoteInvitation Allows the callee to decline a received call invitation.
Caller Event Description
onLocalInvitationReceivedByPeer Callback to the caller: occurs when the callee receives the call invitation.
onLocalInvitationCanceled Callback to the caller: occurs when the caller cancels a sent call invitation.
onLocalInvitationAccepted Callback to the caller: occurs when the callee accepts the call invitation.
onLocalInvitationRefused Callback to the caller: occurs when the callee declines the call invitation.
onLocalInvitationFailure Callback to the caller: occurs when the life cycle of an outgoing call invitation ends in failure. See LocalInvitationError for the error codes.
Callee Event Description
onRemoteInvitationReceived Callback to the callee: occurs when the callee receives a call invitation. At the same time, the SDK returns a RemoteInvitation object to the callee.
onRemoteInvitationAccepted Callback to the callee: occurs when the callee accepts a received call invitation.
onRemoteInvitationRefused Callback for the callee: occurs when the callee declines a received call invitation.
onRemoteInvitationCanceled Callback to the callee: occurs when the caller cancels the call invitation.
onRemoteInvitationFailure Callback to the callee: occurs when the life cycle of the incoming call invitation ends in failure. See RemoteInvitationError for the error code.

Renew the Token

Method Description
renewToken Renews the current token.
Event Description
onTokenExpired Occurs then the Token expires.

Customized method

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