Skip to main content
This page is the full surface of CometChat’s offline support in the React Native Chat SDK: configuration options, public methods, listeners, enums, model fields, and error codes. The minimum SDK version is 4.2.0, and offline support is off by default. For task-focused guides see Enable Offline Support, Show Cached Data, Send While Offline, Stay in Sync, Media Caching, and Encrypt the Cache.

OfflineConfig options

Construct with new CometChat.OfflineConfig(options); every key is optional and pre-set to its default, so pass only the options you want to change. The resulting OfflineConfig is immutable. Invalid values are normalised, never rejected: a wrong type or unknown enum value falls back to the default, and a negative duration becomes 0. Byte caps and the TTL treat <= 0 as unlimited (that dimension’s eviction is disabled); the count caps are clamped and have no “unlimited”. Attach the config at init via AppSettingsBuilder.setOfflineConfig(OfflineConfig), or enable with defaults via the offline(boolean) shorthand — see Enable Offline Support. The config object also exposes read-only getters: isEnabled(), isEncryptionEnabled(), getEncryptionFailureBehavior(), getCacheDurationDays(), getMaxStorageSize(), getMaxMessagesPerConversation(), getMaxConversations(), getMaxSnapshotQueries(), getSnapshotTtlDays(), getMaxPendingMessages(), isAutoSendPendingOnReconnect(), getPendingQueueOverflowPolicy(), getMediaCaching() and getMaxMediaCacheSize().

Public methods on CometChat

On the returned UploadFileRequest, getItems() lists each file’s progress item and retryAttachment(fileId) retries one failed file. New batches are created with CometChat.createUploadFileRequest.

Listener registration

Listeners and callbacks

Two-phase fetch listeners

Pass one as the optional argument of a request’s fetchNext() / fetchPrevious() (or of getConversation() / getMessageDetails()). Each delivers the cached page first (when offline is active and a user is logged in), then the server result, then errors. With offline off the cached callback never fires. The cached callback is optional on every listener. onError is required on all of them; the server callback is required on all except BannedGroupMemberFetchListener and FeedItemFetchListener, where each server callback is optional.

Send, sync, cache, and media listeners

Enums

All enums are available on CometChat (for example CometChat.MessageStatus.PENDING). CometChat.OFFLINE_PENDING_COUNT_UNKNOWN is -1.

Model fields

Error codes

Compare CometChatException.code against these values. The offline codes are available on CometChat.OfflineErrorCode (MESSAGE_DISCARDED, MESSAGE_IN_FLIGHT, MESSAGE_NOT_FOUND, AUTO_FLUSH_CAP_REACHED, PENDING_QUEUE_LIMIT, DISABLED, SYNC_IN_PROGRESS, SYNC_COOLDOWN, MESSAGE_PERSIST_FAILED); compare the others as string values.

Which filters the cache can answer

A cached phase is served only when every filter on the request is locally computable; otherwise the cached phase is empty and only the server phase answers. MessagesRequest.hideMessagesFromBlockedUsers is answered from the cache only after the blocked-users list has been fetched from the server at least once; until then its cached phase is empty. Pinned-only and saved-only message reads are answered from the cache too. All other filters — including message tags, mentions, attachment and reaction filters, hideReplies, hideDeletedMessages, and conversation tags and unread — are answered from the cache.