Pinned messages
Pin messages to channels for easy access. Only one message can be pinned per channel at a time.
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 thread channel or parent channel.
Method signature
- Blueprint
- C++ / Input parameters
-
Message->Pin()1Message->Pin();
2 -
Channel->PinMessage()1Channel->PinMessage(UPubnubMessage* Message);
| Parameter | Required in Pin() | Required in PinMessage() | Description |
|---|---|---|---|
MessageType: UPubnubMessage*Default: n/a | No | Yes | 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). |
Sample code
Pin a message on the incident-management channel.
-
Pin()
show all 16 lines1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11FString Timetoken = "16200000000000001";
12
13// Fetch the message
14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
15 -
PinMessage()1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11// Fetch the message
12UPubnubMessage* Message = Channel->GetMessage(Timetoken);
13
14Channel->PinMessage(Message);
Get
GetPinnedMessage() retrieves the currently pinned message.
Method signature
- Blueprint
- C++ / Input parameters
-
Channel->GetPinnedMessage()1Channel->GetPinnedMessage();
Output
| Type | Description |
|---|---|
UPubnubMessage* | Object returning either the pinned Message object or null value if no message is currently pinned to the channel. |
Sample code
Get the message pinned to the incident-management channel.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11// Fetch the pinned message
12UPubnubMessage* PinnedMessage = Channel->GetPinnedMessage();
Unpin
UnpinMessage() unpins a message from the channel.
Alternatively, unpin thread messages from the thread channel or parent channel.
Method signature
- Blueprint
- C++ / Input parameters
1Channel->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). |
Sample code
Unpin the message from the incident-management channel.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11Channel->UnpinMessage();