Pinned messages
Using Unreal Chat SDK methods, you can implement UI features allowing users to "pin" a message to a channel by selecting a sent message and placing it on top of the channel for everyone to see and access it easily.
They can also "unpin" the message if it's no longer important or "pin" another one to replace an already pinned message (there can be only one pinned message on a channel at a time).
Additionally, they can check which message is pinned to the selected channel since the Unreal Chat SDK uses the channel metadata to store information on such messages in Message Persistence.
Pinned Messages let users highlight messages in channels for:
-
Essential information - pin critical updates or announcements, ensuring important information remains easily accessible to all participants and reducing the chance of missing key details.
-
Action items and reminders - by pinning action items or reminders, users and their teams can have a centralized location for reference, making it easier to stay organized, prioritize tasks, and ensure accountability.
-
Polling - pin a poll to a channel, allowing a pollster to persist their questions and not have them lost in a chat flow.
Requires App Context and Message Persistence
To store modified data about messages, you must enable App Context and Message Persistence for your app's keyset in the Admin Portal.
Pin
Pin()
and PinMessage()
attach a message to the channel.
Both of these methods give the same result. The only difference between them is that you may or may not be required to provide input parameters, and you call them on different objects: message (Message->Pin()
) or channel (Channel->PinMessage()
).
Alternatively, you can also use other Unreal Chat SDK methods to pin a message in a thread (thread message) to the thread channel or the parent channel.
Method signature
- Blueprint
- C++ / Input parameters
-
Message->Pin()
Message->Pin();
-
Channel->PinMessage()
Channel->PinMessage(UPubnubMessage* Message);
Parameter | Type | Required in Pin() | Required in PinMessage() | Default | Description |
---|---|---|---|---|---|
Message | UPubnubMessage* | No | Yes | n/a | Message object that you want to pin to the selected channel. |
Output
Type | In Pin() | In PinMessage() | Description |
---|---|---|---|
void | Yes | No | Method returns no output data. |
UPubnubChannel* | No | Yes | Object returning the channel metadata updated with these custom fields: pinnedMessageTimetoken to mark the timetoken when the message was pinned pinnedMessageChannelID to mark the channel on which the message was pinned to the given channel (pinning was performed either directly on the parent channel or on a thread channel). |
Basic usage
Pin a message on the incident-management
channel.
-
Pin()
show all 16 lines#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("incident-management");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken); -
PinMessage()
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("incident-management");
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
Channel->PinMessage(Message);
Get
GetPinnedMessage()
fetches the message that is currently pinned to the channel.
Method signature
- Blueprint
- C++ / Input parameters
-
Channel->GetPinnedMessage()
Channel->GetPinnedMessage();
Output
Type | Description |
---|---|
UPubnubMessage* | Object returning either the pinned Message object or null value if no message is currently pinned to the channel. |
Basic usage
Get the message pinned to the incident-management
channel.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("incident-management");
// Fetch the pinned message
UPubnubMessage* PinnedMessage = Channel->GetPinnedMessage();
Unpin
UnpinMessage()
unpins a message from the channel.
Alternatively, you can also use other Unreal Chat SDK methods to unpin a message in a thread (thread message) from the thread channel or the parent channel.
Method signature
- Blueprint
- C++ / Input parameters
Channel->UnpinMessage();
Output
Type | Description |
---|---|
UPubnubChannel* | Object returning the channel metadata updated with these custom fields: pinnedMessageTimetoken to mark the timetoken when the message was unpinned pinnedMessageChannelID to mark the channel on which the message was unpinned from the given channel (unpinning was performed either directly on the parent channel or on a thread channel). |
Basic usage
Unpin the message from the incident-management
channel.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("incident-management");
Channel->UnpinMessage();