savedAt is per-viewer. It is only ever populated in the acting user’s own
context — you will never see another user’s saves on a message.Save a Message
CallsaveMessage() with the message’s ID. It resolves with the full updated message, with savedAt set.
- TypeScript
- JavaScript
Unsave a Message
- TypeScript
- JavaScript
savedAt cleared, never left stale.
Fetch Saved Messages
Build aMessagesRequest with setSaved(true). The saved list is user-level, so unlike the pinned list you do not set a UID or a GUID — leaving both unset is what makes it cross-conversation.
- TypeScript
- JavaScript
fetchPrevious() again on the same object to page through older entries.
Because the list spans conversations, every row carries its own context — use getConversationId(), getReceiverId() and getReceiverType() to route a tap on a saved message back to the right conversation.
- TypeScript
- JavaScript
fetchNext() on a setSaved(true) request accepts a MessageFetchListener: it delivers a cached page first (onCachedMessages, even when empty) and then the server list (onServerMessages). Offline, the read ends with onError with code FAILED_TO_FETCH after the cached page. onCachedMessages holds the user’s cached saved messages across all conversations. The saved list is answered from its own list, not from the message cache, so the other filters on the request do not apply to it.
Check if a Message is Saved
The presence ofsavedAt is the boolean — an unsaved message simply has no save attribute.
- TypeScript
- JavaScript
Real-time Save Events
Save and unsave are private multi-device events: they are delivered to the user’s other logged-in sessions so a save on the phone shows up on the desktop. Add the callbacks to your existingMessageListener.
- TypeScript
- JavaScript
These callbacks fire for saves made on your other devices, not the one that
performed the save — that device already has the message resolved from
saveMessage(). Update your saved list from the promise there, and from these
callbacks everywhere else.Save Limit
A user may save a capped number of messages across all conversations. Read the cap from app settings rather than hard-coding it.- TypeScript
- JavaScript
null when the app settings carry no value — show generic copy in that case rather than guessing a number.
Error Handling
saveMessage() and unsaveMessage() reject with a CometChatException. Branch on the code rather than the message text:
Saving is per-user, so there is no role gate: any participant can save a message they have access to, up to the cap.
- TypeScript
- JavaScript
Read the cap from
CometChat.getSavedMessagesLimit(), which resolves to the configured cap, or null when unset — so you can name the exact number in your own copy without parsing it out of the error text.Feature Availability
- TypeScript
- JavaScript
false rather than rejecting when the flag is missing or settings are unavailable.
Next Steps
Pin A Message
Highlight a message for everyone in a conversation
Pin A Conversation
Pin a conversation to the top of the list
Retrieve Conversations
Fetch and order the conversation list
Additional Message Filtering
Filter messages by saved, pinned, type, tags and more