Repository navigation
v4.2.0
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-sqlite9.0.0 or later,react-native-fs, andreact-native-keychain. These dependencies are loaded only when offline support is initialized. -
Introduced
OfflineConfigto configure cache size and lifetime, pending-message limits, queue overflow policies, automatic message delivery after reconnection, media caching, and encryption. -
Added optional
MessageSentListenersupport tosendMessage(),sendMediaMessage(),sendCustomMessage(), andsendInteractiveMessage(). When offline support is enabled, messages sent with a listener are queued and delivered when connectivity returns. AddedgetPendingMessages(),retryMessage(),retryAllFailedMessages(), anddiscardLocalMessage()to manage pending messages, along withaddOfflineMessageListener()to monitor queue updates. -
Added optional listener support to
fetchNext(),fetchPrevious(),getMessageDetails(), andgetConversation(). Listeners such asConversationFetchListenerandMessageDetailsListenerreceive cached results first, followed by updated results from the server. -
Added
getSyncState(),getLastSyncTimestamp(),forceSyncNow(), andaddSyncListener()to monitor and control synchronization. IntroducedgetCacheSize()andclearOfflineCache()for cache management, along withdownloadMedia(),getCachedMediaPath(), andaddMediaDownloadListener()for media management. -
Added optional encryption at rest through
encryption: true, using SQLCipher throughop-sqlite. Encryption keys are stored in the platform keychain or in a custom vault configured throughsetOfflineKeyVault(). AddedgetOfflineEncryptionStatus()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(), andgetSource()to messages, along withgetLocalPath()to attachments. -
Enhanced
UploadFileRequestwithgetItems()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)invokesonMessagePending, followed byonError(error, reason)withreasonset tonulland the error code set toFAILED_TO_FETCH. The returned Promise rejects while the message remains queued. Do not resend the message when this error occurs. Identify this queued state usingreason == nullorerror.errorParams.queued === true. The SDK invokesonMessageSentwhen 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
FAILEDstatus are not retried automatically. UseretryMessage()to retry an individual failed message orretryAllFailedMessages()to retry messages that failed with theTRANSIENTstatus. -
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()andaddOfflineMessageListener()immediately afterawait CometChat.init(), before awaiting other operations. This ensures that startup notifications are received. -
Updated encryption behavior when
PLAINTEXT_FALLBACKis enabled. Applications must provide a key store throughreact-native-keychainorsetOfflineKeyVault(). Without a key store, the SDK deletes the cache on every launch and marks unsent messages from the previous launch asDISCARDED. -
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 returnedERROR_LIMIT_EXCEEDED.
Fixes
-
Fixed an issue where
MediaMessage.getAttachment()threw an error when called on a message without attachments. The method now returnsnullwhen no attachments are available. -
Fixed an issue where combining
pinnedOnly(true)andsavedOnly(true)caused aPINNED_AND_SAVED_BOTH_SETerror. 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-storageare now peer dependencies. Add@react-native-async-storage/async-storageto 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. UsesetAttachments([attachment])when replacing existing attachments is required.