saveMessage static method

Future<BaseMessage?> saveMessage(
  1. int messageId, {
  2. dynamic onSuccess(
    1. BaseMessage
    )?,
  3. dynamic onError(
    1. CometChatException excep
    )?,
})

Save (bookmark) a message for the logged-in user.

Saves are private and per-viewer — no other member is notified, and any readable message (own or others') can be saved. The returned message carries savedAt stamped. Idempotent. On the cap error ERR_SAVED_MESSAGES_LIMIT_EXCEEDED, errorParams carries the limit.

This device fires MessageListener.onMessageSaved once for its own call, before onSuccess. The server self-echoes a socket frame, which the armed marker drops so the listener still fires exactly once; the user's other devices also fire it. 5.1.0 keeps the 5.0.9 same-device callback for UI Kit compatibility; see BEH-FLAG-04.

Implementation

static Future<BaseMessage?> saveMessage(
  int messageId, {
  Function(BaseMessage message)? onSuccess,
  Function(CometChatException e)? onError,
}) {
  return _pinSaveFacadeCall(
    messageId,
    'saved',
    (sdk, id) => sdk.messages.saveMessage(id),
    onSuccess,
    onError,
  );
}