Skip to content

4.2.0

Choose a tag to compare

@cometchat cometchat released this 02 Nov 12:56
· 1 commit to v4 since this release
3f89c26

v4.2.0

New

  • Added optional offline support, disabled by default. Enable it using AppSettings.AppSettingsBuilder().setOfflineConfig(OfflineConfig.Builder().setEnabled(true).build()). The SDK maintains an on-device cache of conversations, messages, users, groups, and media for the logged-in user, serves cached results first, queues outgoing messages, and synchronizes data when connectivity is restored.

  • Introduced OfflineConfig.Builder to configure cache size and lifetime, pending-message limits, queue overflow policies, automatic message delivery after reconnection, media caching, and encryption. Added CometChat.isOfflineEnabled() to check whether offline support is currently active, including when its state changes during a session.

  • Added listener-based overloads to sendTextMessage, sendMediaMessage, sendCustomMessage, and sendInteractiveMessage, supporting onMessagePending, onMessageSent, and onError callbacks. When offline support is enabled, these methods queue messages sent without an active connection and deliver them when connectivity returns, including after an application restart.

  • Added getPendingMessages(onSuccess:onError:), retryMessage(_:), retryAllFailedMessages(), and discardLocalMessage(_:) to manage queued messages. Introduced OutboxListener, registered through CometChat.addOutboxListener(_:_:), to monitor outbox updates.

  • Added cached-result and server-result listener overloads to MessagesRequest, ConversationRequest, UsersRequest, GroupsRequest, GroupMembersRequest, BannedGroupMembersRequest, BlockedUserRequest, ThreadsRequest, ReactionsRequest, and NotificationFeedRequest. These methods deliver locally cached results first, followed by updated server results. Added the same functionality to getConversation(conversationWith:conversationType:listener:) and getMessageDetails(_:listener:) through ConversationDetailsListener and MessageDetailsListener.

  • Introduced getSyncState(), getLastSyncTimestamp(), and forceSyncNow(onSuccess:onError:) to monitor and control synchronization. Added SyncListener and CometChatMessageDelegate.onMessagesSynced(_:) to receive synchronization updates.

  • Added downloadMedia(url:messageServerId:onProgress:onSuccess:onError:) and getCachedMediaPath(_:) to download and access locally cached media. Introduced Attachment.localPath and MediaDownloadListener to support local media access and download monitoring.

  • Added getExistingUploadFileRequest(receiverId:receiverType:parentMessageId:) to restore an upload batch associated with a chat after an application restart. Enhanced UploadFileRequest.getItems() to retrieve every file in the batch with its upload state, and added support for retrying restored files through retryAttachment(fileId:) using the SDK's locally stored copy.

  • Added optional encryption at rest through setEncryption(true), using a bundled SQLCipher implementation that avoids conflicts with the application's existing SQLite, SQLCipher, GRDB, or FMDB dependencies. Encryption keys are stored in the Keychain, and getOfflineEncryptionStatus() reports the active encryption status.

  • Added clearOfflineCache() and getCacheSize() for offline cache management. Introduced OfflineCacheResetListener to report when the cache is rebuilt and indicate how many unsent messages were lost.

  • Added read-only BaseMessage.localMessageId and BaseMessage.source properties to identify locally stored messages and their origin.

  • Updated offline message delivery behavior when connectivity is unavailable. With offline support enabled, listener-based message sends invoke onMessagePending, followed by onError with ERROR_INTERNET_UNAVAILABLE, while keeping the message queued. Do not resend the message when this error occurs. The SDK invokes onMessageSent when connectivity returns, while onOutboxMessageFailed(_:_:) reports messages that ultimately fail.

  • Introduced manual retry handling for failed messages. Failed messages are not retried automatically. Use retryMessage(_:) to retry an individual message or retryAllFailedMessages() to retry all failed messages.

  • Introduced at-least-once delivery for queued messages. Duplicate messages may appear in a conversation if the server accepts a request but its response does not reach the SDK.

  • Updated offline data retention behavior so that logging out or switching to a different user deletes that user's offline cache and unsent messages.

  • Updated getCacheSize() to read cache information from disk. Call this method off the main thread to avoid blocking the application's main thread.

  • Excluded the offline cache database and cached media, including unsent upload data, from iCloud and device backups.

Enhancements

  • Increased the maximum supported page size for ReactionsRequest to 1000 reactions. Values exceeding 1000 are automatically capped at 1000. Previously, limits greater than 20 returned ERROR_LIMIT_EXCEEDED.

Fixes

  • Fixed an issue where the WebSocket connection could remain disconnected after multiple connection drops. Previously, after the first successful reconnection, subsequent drops were retried only once, potentially requiring an application restart to restore connectivity.

  • Fixed a heartbeat issue that could disconnect a newly established WebSocket connection. When a connection dropped and recovered within approximately three seconds of a heartbeat, the previous heartbeat check could incorrectly close the new connection. This fix also applies to manual ping() calls when autoEstablishSocketConnection is disabled.

  • Fixed pagination for pinned and saved message lists. Pages after the first now continue from the correct position in the server's previous page, preventing duplicate or missing messages when loading additional results.

  • Fixed an issue where a MessagesRequest containing both pinned and saved filters could return no results because both filters were sent to the server. The request now returns the saved message list when both filters are specified.

Privacy

  • Updated the SDK privacy manifest to declare its use of file timestamp, system boot time, and disk space APIs. No application changes are required; Xcode automatically includes these declarations in the application's privacy report.