pinMessage static method

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

Pin a message to its conversation.

Pins are conversation-global: every member sees the pin. Group pinning is permissioned server-side (admin/moderator/owner); 1-1 conversations allow both participants. The response — and onSuccess — carry the full updated message with pinnedAt/pinnedBy stamped. Idempotent: pinning an already-pinned message succeeds with the current state.

On the cap error ERR_PINNED_MESSAGES_LIMIT_EXCEEDED, the exception's errorParams map carries {"limit": <n>}.

This device fires MessageListener.onMessagePinned once for its own call, before onSuccess. Every other member, and the user's own other devices, also receive that event. 5.1.0 keeps the 5.0.9 same-device callback for UI Kit compatibility; see BEH-FLAG-04.

Implementation

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