Get message details
Get message details, retrieve content, and check if the message was deleted.
Get message details
GetMessage()
fetches the Message
object from Message Persistence based on the message timetoken.
- Blueprint
- C++ / Input parameters
Channel->GetMessage(FString Timetoken);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Timetoken | FString | No | n/a | Timetoken of the message you want to retrieve from Message Persistence. |
Output
Type | Description |
---|---|
UPubnubMessage* | Returned Message object. |
Basic usage
Get the message with the 16200000000000001
timetoken.
#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("support");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
Get historical details
If you have Message Persistence enabled on your keyset, PubNub stores all historical info about messages, their metadata, and reactions.
If you want to fetch historical details of a given message, use the GetHistory()
method. By default, when you fetch historical messages, PubNub returns all message reactions and metadata attached to the retrieved messages.
Get message content
You can use the getter method to access the Message
object and receive its text content using the text
method.
Method signature
- Blueprint
- C++ / Input parameters
Message->Text();
Output
Type | Description |
---|---|
FString | Text content of the returned message. |
Basic usage
Get the content of the message with the 16200000000000000
timetoken.
#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("support");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
show all 16 linesCheck deletion status
You can use the getter methods to access the Message
object and check if it was deleted using the deleted
method.
Method signature
- Blueprint
- C++ / Input parameters
Message->Deleted();
Output
Type | Description |
---|---|
bool | Info on whether the message has the deleted status (because it was previously soft-deleted) or not. |
Basic usage
Get the status of the message with the 16200000000000000
timetoken.
#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("support");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
show all 16 lines