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.
renewToken Renews the current token.
queryPeersOnlineStatus

Queries the online status of the specified user(s).

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.
getChannelId Gets the channel ID.

RtmCallManager Methods

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

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.
onTokenExpired Your token has expired.
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.