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

RtmClient Methods

Method Description
createInstance Creates and returns an RtmClient instance.
release Releases all resources used by the RtmClient instance.
login Allows a user to log 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 Allows a user to log 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.
createMessage Creates and returns an io.agora.rtm.RtmMessage instance.
sendMessageToPeer Allows a local user to send a peer-to-peer message to a specific remote user.
createChannel Creates an Agora RTM channel.
  • Success: Returns an RtmChannel instance.
  • Failure: Returns null.
getRtmCallManager Gets the Agora RTM call manager.

RtmMessage Methods

Method Description
setText Sets the channel or peer-to-peer text message. Maximum length is 32 KB.
getText Retrieves the channel or peer-to-peer text message.

RtmChannel Methods

Method Description
join Allows a user to join a channel.
leave Allows a user to leave a channel.
sendMessage Allows a user to send a message to all users in a channel.
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.
getId Gets the channel ID.
release Releases all resources of the current channel.

RtmChannelMember Methods

Method Description
getUserId Gets the user ID of a user in the channel.

RtmCallManager Methods

Method Description
setEventListener Sets the event listener of an RtmCallManager instance.
createLocalInvitation Creates a call invitation.
sendLocalInvitation Allows a local user (the caller) to send a call invitation to a remote user (the callee).
acceptRemoteinvitation Allows a local user (the callee) to accept a call invitation from a remote user (the caller).
refuseRemoteInvitation Allows a local user (the callee) to refuse a call invitation from a remote user (the caller).
cancelLocalInvitation Allows a local user (the caller) to cancel a call invitation to a remote user (the callee).

Callbacks

Method Description
RtmChannelListener.onMessageReceived Occurs when the local user receives a channel message.
onMemberJoined Occurs when a remote user joins a channel.
onMemberLeft Occurs when a remote user leaves a channel.
onConnectionStateChanged

Occurs when a connection state changes between the SDK and the Agora RTM system.

Returns the new connection state and the reason for the connection state change.

RtmClientListener.onMessageReceived Occurs when the local user receives a peer-to-peer message.
onLocalInvitationReceivedByPeer Callback to the caller: occurs when the callee receives the call invitation.
onLocalInvitationAccepted Callback to the caller: occurs when the callee accepts the call invitation.
onLocalInvitationRefused Callback to the caller: occurs when the callee refuses the call invitation.
onLocalInvitationCanceled Callback to the caller: occurs when the caller cancels a call invitation.
onLocalInvitationFailure Callback to the caller: occurs when the caller's call invitation fails.
onRemoteInvitationReceived Callback to the callee: occurs when the callee receives a call invitation.
onRemoteInvitationAccepted Callback to the callee: occurs when the callee accepts a call invitation.
onRemoteInvitationRefused Callback for the callee: occurs when the callee refuses a call invitation.
onRemoteInvitationCanceled Callback to the callee: occurs when the caller cancels the call invitation.
onRemoteInvitationFailure Callback to the callee: occurs when the call invitation fails.