On this page

Pinned messages

Pin messages to channels for easy access. Only one message can be pinned per channel at a time.

icon

Usage in Blueprints and C++


Use cases:

  • Essential announcements and updates
  • Action items and reminders
  • Polls and persistent questions
Requires App Context and Message Persistence

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

Output

TypeIn 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()

    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
    11FString Timetoken = "16200000000000001";
    12
    13// Fetch the message
    14UPubnubMessage* Message = Channel->GetMessage(Timetoken);
    15
    show all 16 lines
  • 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

Output

TypeDescription
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

Output

TypeDescription
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();
Last updated on