Skip to content

v4.2.0

Choose a tag to compare

@raj-dubey1 raj-dubey1 released this 02 Nov 12:46
· 1 commit to v4 since this release
65c9fcc

New

  • Added optional offline support, disabled by default. Enable it using new CometChat.AppSettingsBuilder().setOfflineConfig(new CometChat.OfflineConfig({ enabled: true })) or .offline(true) to use the default configuration. The SDK maintains an on-device cache for each app and user, serves cached results first, queues outgoing messages, and synchronizes data when connectivity is restored.

  • Added support for three optional peer dependencies required for offline functionality: @op-engineering/op-sqlite 9.0.0 or later, react-native-fs, and react-native-keychain. These dependencies are loaded only when offline support is initialized.

  • Introduced OfflineConfig to configure cache size and lifetime, pending-message limits, queue overflow policies, automatic message delivery after reconnection, media caching, and encryption.

  • Added optional MessageSentListener support to sendMessage(), sendMediaMessage(), sendCustomMessage(), and sendInteractiveMessage(). When offline support is enabled, messages sent with a listener are queued and delivered when connectivity returns. Added getPendingMessages(), retryMessage(), retryAllFailedMessages(), and discardLocalMessage() to manage pending messages, along with addOfflineMessageListener() to monitor queue updates.

  • Added optional listener support to fetchNext(), fetchPrevious(), getMessageDetails(), and getConversation(). Listeners such as ConversationFetchListener and MessageDetailsListener receive cached results first, followed by updated results from the server.

  • Added getSyncState(), getLastSyncTimestamp(), forceSyncNow(), and addSyncListener() to monitor and control synchronization. Introduced getCacheSize() and clearOfflineCache() for cache management, along with downloadMedia(), getCachedMediaPath(), and addMediaDownloadListener() for media management.

  • Added optional encryption at rest through encryption: true, using SQLCipher through op-sqlite. Encryption keys are stored in the platform keychain or in a custom vault configured through setOfflineKeyVault(). Added getOfflineEncryptionStatus() to report the active encryption status.

  • Introduced addOfflineCacheResetListener() to notify applications when the offline cache is rebuilt and report the number of unsent messages lost during the reset.

  • Added getLocalMessageId(), getMessageStatus(), and getSource() to messages, along with getLocalPath() to attachments.

  • Enhanced UploadFileRequest with getItems() to retrieve all files in a batch, in the order they were added, including their individual upload states.

  • Updated offline message delivery behavior when connectivity is unavailable. With offline support enabled, calling sendMessage(message, listener) invokes onMessagePending, followed by onError(error, reason) with reason set to null and the error code set to FAILED_TO_FETCH. The returned Promise rejects while the message remains queued. Do not resend the message when this error occurs. Identify this queued state using reason == null or error.errorParams.queued === true. The SDK invokes onMessageSent when connectivity returns. Messages sent without a listener are not queued and continue to reject as before.

  • Introduced manual retry handling for failed messages. Messages with the FAILED status are not retried automatically. Use retryMessage() to retry an individual failed message or retryAllFailedMessages() to retry messages that failed with the TRANSIENT status.

  • 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.

  • Required applications using offline support to register addOfflineCacheResetListener() and addOfflineMessageListener() immediately after await CometChat.init(), before awaiting other operations. This ensures that startup notifications are received.

  • Updated encryption behavior when PLAINTEXT_FALLBACK is enabled. Applications must provide a key store through react-native-keychain or setOfflineKeyVault(). Without a key store, the SDK deletes the cache on every launch and marks unsent messages from the previous launch as DISCARDED.

  • Updated offline data retention behavior so that logging in as a different user deletes the previous user's offline cache, even if the new login fails.

Enhancements

  • Increased the maximum supported limit in ReactionsRequestBuilder.setLimit() to 1000. Values exceeding 1000 are automatically capped at 1000. Previously, limits greater than 20 returned ERROR_LIMIT_EXCEEDED.

Fixes

  • Fixed an issue where MediaMessage.getAttachment() threw an error when called on a message without attachments. The method now returns null when no attachments are available.

  • Fixed an issue where combining pinnedOnly(true) and savedOnly(true) caused a PINNED_AND_SAVED_BOTH_SET error. The request now returns the saved message list, matching server behavior.

  • Fixed pagination for saved message lists. Pages after the first now use the cursor returned by the server, preventing messages from being skipped or repeated when loading additional results.

Breaking Changes

  • Changed the package dependency installation behavior. The package no longer installs its own dependencies, and react, react-native, and @react-native-async-storage/async-storage are now peer dependencies. Add @react-native-async-storage/async-storage to your application dependencies if it is not already installed.

  • Changed MediaMessage.setAttachment() to append attachments instead of replacing existing ones, regardless of whether offline support is enabled. Calling the method multiple times now includes all added attachments in the outgoing message. Use setAttachments([attachment]) when replacing existing attachments is required.