Skip to main content

Manage Offline Message Storage Configuration

The IM service supports modifying offline message configurations at both the App level and user level.

tip

Offline message configurations are only applicable to one-to-one chat and group chat. Chatroom and ultra group do not support offline messages due to their business characteristics, hence there are no offline message configurations for them.

Understanding Offline Messages

Offline messages? refer to messages received when a user is offline. The RC server automatically retains messages received during the offline period for users, with a default retention period of 7 days. If the client comes online within 7 days, the server will directly send the offline messages to the receiving end. If the client does not come online within 7 days, the server will discard the expired messages.

Not all conversation types in the IM service support offline messages:

  • Offline messages supported: one-to-one chat, group chat, system message
  • Offline messages not supported: chatroom, ultra group

App-Level Offline Message Configuration

You can modify the following App-level offline message storage settings:

  • Offline message storage duration. You can modify the storage duration in the RC Console under Configuration > Chat settings > Basic features > One-to-One and Group Chat > Set Offline Message Storage Duration. Messages received by the target user while offline will be saved in offline messages, with a default storage period of 7 days. The user will receive these offline messages upon their next login. If adjustments are needed, you can set the duration here, with a range of 1 to 7 days. This setting is only effective for one-to-one chat, group chat, and system message conversation types.
  • Group offline message storage duration. When the target user is offline, group messages received by the user will be stored in offline messages, with a default storage period of 7 days. The user can retrieve these messages upon their next login. If this setting is not configured, the group's offline message storage duration will be controlled by the "Set Offline Message Storage Duration" setting. If this setting is configured, the offline storage duration for group messages will follow this configuration.
  • Group offline message storage quantity. By default, all group messages within 7 days are stored. You can submit a ticket to modify this configuration. Configuration changes will affect all group chat sessions under the App.

User-Level Offline Message Configuration

tip

The functions to set and retrieve a user's offline message storage duration require the User-Level Feature Settings to be enabled. To enable this feature, please submit a ticket.

The IM service supports user-level offline message configurations, allowing only the modification of the offline message storage duration. If not modified, the user's offline message storage duration is 7 days. The setting range is 1 to 7 days.

After the App Key enables the User-Level Feature Settings function, the client SDK supports modifying the offline message storage duration for the currently logged-in user.

Set User's Offline Message Storage Duration

Set the offline message storage duration for the current user, in days.

int duration = 3;

RongIMClient.getInstance().setOfflineMessageDuration(duration, new RongIMClient.ResultCallback<Long>() {
@Override
public void onSuccess(Long aLong) {

}

@Override
public void onError(RongIMClient.ErrorCode e) {

}
});
ParameterTypeDescription
durationintOffline message storage duration, range from 1 to 7 days.
callbackRongIMClient.ResultCallback<Long>Callback interface.

Get User's Offline Message Storage Duration

Get the offline message storage duration for the current user, in days.

RongIMClient.getInstance().getOfflineMessageDuration(new RongIMClient.ResultCallback<String>() {
@Override
public void onSuccess(String s) {

}

@Override
public void onError(RongIMClient.ErrorCode e) {

}
});
ParameterTypeDescription
callbackRongIMClient.ResultCallback<String>Callback interface.