You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Added offline messaging, which is opt-in and off by default. While it is enabled, reads made with the two-phase fetch listeners return cached results first and then server results, and each reconnect catches the cache up with changes made on the server. A large backlog catches up over several reconnects, and SyncOutcome.PARTIAL reports that more remains. Enable it with AppSettingsBuilder.setOfflineConfig(new OfflineConfig.Builder().enabled(true).build()), or with AppSettingsBuilder.offline(true) to use the defaults.
Added two-phase fetch listeners that deliver the cached page first (onCached…) and then the server page (onServer…): MessageFetchListener (MessagesRequest), ConversationFetchListener, UserFetchListener (UsersRequest, BlockedUsersRequest), GroupFetchListener, GroupMemberFetchListener, BannedGroupMemberFetchListener, ReactionFetchListener, ThreadsFetchListener and NotificationFeedFetchListener, plus MessageDetailsListener for CometChat.getMessageDetails and ConversationDetailsListener for CometChat.getConversation. Implement the onCached… callback to show cached results. The CallbackListener overloads of these fetch methods are deprecated; they still work as in v5.0.x and return only the server page.
Added MessageSentListener overloads of CometChat.sendMessage, sendMediaMessage and sendCustomMessage. onMessagePending fires when the message is queued, and onMessageSent fires when the server accepts it, including after a reconnect for a message queued offline.
Added an outbox for messages sent while offline. Queued messages are sent in order, and a send that gets no answer from the server waits, together with the messages queued behind it in its conversation, until the connection reconnects or retryMessage is called.
Increased the distributable AAR from about 1.1 MB (v5.0.7) to about 1.8 MB to include offline messaging. The increase applies whether or not offline messaging is enabled.
Added OfflineConfig.Builder options that limit the cache: cacheDurationDays, maxStorageSize, maxMessagesPerConversation and maxConversations.
Added OfflineConfig.Builder options that control the outbox: maxPendingMessages, pendingQueueOverflowPolicy (PendingMessageOverflowPolicy) and autoSendPendingOnReconnect.
Added OfflineConfig.Builder options for cached media, mediaCaching (MediaCachingMode) and maxMediaCacheSize, and debugTracing for diagnostic logging.
Added CometChat.getPendingMessages(callback), CometChat.retryMessage(localMessageId, listener) and CometChat.retryAllFailedMessages(listener) to read and resend queued messages. retryMessage sends a failed or waiting message now, after any earlier unsent messages in its conversation.
Added error codes so that retryMessage always answers: ERROR_OFFLINE_MESSAGE_IN_FLIGHT for a message that is sending, ERROR_OFFLINE_MESSAGE_NOT_FOUND for an unknown or already-sent id, and ERROR_OFFLINE_DISABLED when offline messaging is not enabled.
Added CometChat.discardLocalMessage(localMessageId, callback), which deletes an unsent (waiting or failed) message from the device, together with its media copy, its reply-count increase on the parent and its place as the conversation's last message. It works offline, sends nothing to the server and fires no send callback. It rejects a message that is sending, or an unknown or already-sent id, with the same error codes as retryMessage.
Added BaseMessage.getFailureReason(), which returns the MessageFailureReason of a failed message and null for any other status. TRANSIENT means a retry may succeed.
Added BaseMessage.getLocalMessageId(), a stable client-side handle that is set before sendMessage() returns while offline messaging is enabled.
Added MessageStatus, MessageFailureReason and MessageSource to report where a message stands in the outbox and where a cached read came from.
Added CometChat.addOfflineMessageListener(id, listener) and CometChat.removeOfflineMessageListener(id), which report pending, sent and failed outbox messages.
Added CometChat.forceSyncNow() and CometChat.forceSyncNow(callback) to start a sync, CometChat.getSyncState() (SyncState) and CometChat.getLastSyncTimestamp() to report on it, and CometChat.addSyncListener(id, listener) and CometChat.removeSyncListener(id) (SyncListener, SyncOutcome) to follow its progress.
Added cache management with CometChat.isOfflineEnabled(), CometChat.getCacheSize() and CometChat.clearOfflineCache().
Added media caching with CometChat.downloadMedia(attachment, callback), CometChat.addMediaDownloadListener(id, listener) and CometChat.removeMediaDownloadListener(id). CometChat.getCachedMediaPath(attachment) returns the local path of an attachment's cached file, or null if it is not cached, and CometChat.getMediaCachingMode() returns the media caching mode in effect.
Added optional encryption at rest for the offline cache with OfflineConfig.Builder.encryption(true) and encryptionFailureBehavior (EncryptionFailureBehavior). To use it, add implementation 'net.zetetic:sqlcipher-android:4.13.0' to the app. CometChat.getOfflineEncryptionStatus() (OfflineEncryptionStatus) reports the state.
Added CometChat.addOfflineCacheResetListener(id, listener) and CometChat.removeOfflineCacheResetListener(id), called with an OfflineCacheResetReason (KEY_LOST, WRONG_KEY, CORRUPTED, ESCALATED, ENCRYPTION_CHANGED, SCHEMA_RESET) when the SDK has to wipe the cache and rebuild it from the server. Queued unsent messages are lost on a reset, and SCHEMA_RESET means the cache was created by a newer SDK version, for example after an app rollback. Kotlin code that uses an exhaustive when over this enum must handle every value.
Enhancements
Improved ReactionsRequest to accept any limit up to 1000, matching the server. A larger limit is now treated as 1000 instead of failing with ERROR_LIMIT_EXCEEDED, and the default page size is unchanged.
Placed the offline database and cached media in app storage that Android Auto Backup never includes (no_backup). Chat history is never copied into a user's Google backup or counted toward its size limit, and on a restored or new device the cache is rebuilt from the server.
Fixes
None
Breaking Changes
Changed the default direction of BlockedUsersRequest to match the server. A request built without setDirection(...) now returns only the users the logged-in user blocked (DIRECTION_BLOCKED_BY_ME), where v5.0.x returned DIRECTION_BOTH. To keep the v5.0.x result, call setDirection(BlockedUsersRequest.DIRECTION_BOTH) on the BlockedUsersRequestBuilder.
Changed MediaMessage.getAttachment() to always return the first attachment, because setAttachment(attachment) adds to the attachment list. Before, after setAttachment(a) and then setAttachment(b), getAttachment() returned b; now it returns a. To replace the attachments, call setAttachments(list).