Skip to main content
This page is the full surface of CometChat’s offline support on iOS: 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

Build with OfflineConfig.Builder, or with the Swift initializer OfflineConfig(enabled:encryption:…), whose arguments all default to the values below. The resulting OfflineConfig is immutable. Byte caps and the TTL treat 0 or less as unlimited (that dimension’s eviction is disabled); the count caps are clamped and have no “unlimited”. Attach the config at init via AppSettings.AppSettingsBuilder.setOfflineConfig(_:) — see Enable Offline Support. Each value is readable on the built OfflineConfig (for example offlineConfig.maxConversations), and AppSettings.offlineConfig exposes the active config read-only.

Public methods on CometChat

On the returned UploadFileRequest, getItems() lists each file’s UploadFileItemStatus, and retryAttachment(fileId:) retries one failed file. See Upload Files.

Listener registration

Listeners are held weakly — keep a strong reference — and each ID holds one listener, so use a distinct ID per listener.

Listeners and callbacks

Two-phase fetch overloads

iOS expresses the two-phase read as onCached… / onServer… / onError closure overloads of the existing fetch methods. The only listener protocols on the read path are ConversationDetailsListener and MessageDetailsListener. With offline off the cached closure never fires.

Send, outbox, sync, cache, and media callbacks

All listener methods are optional (@objc optional).

What the cache can answer

The cached phase answers a read only if every active filter is locally computable; one server-only filter returns an empty cached page (the server phase still answers in full). Enrichment flags never block the cached phase.

Enums

The enums are available as CometChat.<Name> in Swift (for example CometChat.MessageStatus). In Objective-C they are named CometChat<Name> (for example CometChatMessageStatus).

Model fields

Error codes

Compare CometChatException.errorCode against these CometChatConstants.Errors constants. A background download that fails reports onMediaDownloadFailed with the error code string "ERROR_MEDIA_DOWNLOAD_FAILED", which is not a CometChatConstants.Errors constant.

Legacy overloads

The classic single-callback overloads are not deprecated on iOS. They are unchanged and never deliver a cached or pending result. The two-phase and pending-aware overloads are additive, and you choose between them by argument label. Only these are deprecated: The entity-list requests (UsersRequest, GroupsRequest, GroupMembersRequest, BannedGroupMembersRequest, BlockedUserRequest, ReactionsRequest, NotificationFeedRequest) follow the same pattern: keep fetchNext(onSuccess:onError:) or add the onCached… / onServer… overload listed above.