Pinned messages
Pin messages to channels for easy access. Only one message can be pinned per channel at a time.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Channel->PinMessageAsync(Message, OnPinMessageResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Channel->PinMessage(Message);
Use cases:
- Essential announcements and updates
- Action items and reminders
- Polls and persistent questions
Requires App Context and Message Persistence
Enable App Context and Message Persistence in the Admin Portal.
Pin
Pin() and PinMessage() attach a message to a channel. Call Pin() on a message object or PinMessage() on a channel object.
Alternatively, pin thread messages to the parent channel.
Method signature
-
Message->Pin()1Message->Pin(); -
Channel->PinMessage()1Channel->PinMessage(UPubnubChatMessage* Message);
| Parameter | Required in Pin() | Required in PinMessage() | Description |
|---|---|---|---|
MessageType: UPubnubChatMessage*Default: n/a | No | Yes | Message object that you want to pin to the selected channel. |
Output
| Method | Return type | Description |
|---|---|---|
Message->Pin() | FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Channel->PinMessage() | FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Pin a message to its channel asynchronously.
PinMessage()(onChannel)
1
Other examples
Pin message to channel from Chat object
Actor.h
1
Actor.cpp
1
Get
GetPinnedMessage() retrieves the currently pinned message.
Method signature
1Channel->GetPinnedMessage();
Output
| Field | Type | Description |
|---|---|---|
Result | FPubnubChatOperationResult | Operation result with Error and ErrorMessage. |
Message | UPubnubChatMessage* | The pinned Message object, or null if no message is currently pinned to the channel. |
Sample code
Get the message pinned to the incident-management channel.
1
Unpin from message
Unpin() called on a message object unpins it from the channel.
Method signature
1Message->Unpin();
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Sample code
Unpin a message.
- C++
- Blueprint
1
Unpin from channel
UnpinMessage() called on a channel object unpins the currently pinned message from the channel.
Alternatively, unpin thread messages from the parent channel.
Method signature
1Channel->UnpinMessage();
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Result of the operation. Check Error and ErrorMessage for failure. |
Sample code
Unpin the message from the incident-management channel.
1
Other examples
Unpin message from channel from Chat object
Actor.h
1
Actor.cpp
1