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.

Fans out MessageListener.onMessageSaved locally on success; the server additionally self-echoes a socket frame to the user's other devices for cross-device sync.

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,
  );
}