Message Reactions API for PubNub Unreal SDK

Add or remove actions on published messages to build features like receipts, reactions, or to associate custom metadata to messages. Clients can subscribe to a channel to receive message reaction events on that channel. They can also fetch past message reactions from Message Persistence independently or when they fetch original messages.

icon

Usage in Blueprints and C++

Terminology

All message reactions in code are collectively called message reactions in the docs and the term applies both to reacting to a message (through emojis) and acting on a message (by deleting it).

Add Message Reaction

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Add a reaction to a published message.

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString Channel = "randomChannel";
FString MessageTimeToken = "5610547826969050";
EPubnubActionType ActionType = EPubnubActionType::pbactypReaction; // Example action type
FString Value = "\"smiley_face\""; // JSON describing the action

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnAddMessageActionsResponse OnAddMessageActionResponse;
OnAddMessageActionResponse.BindDynamic(this, &AMyActor::OnAddMessageActionResponse);
show all 18 lines

Returns

This method returns the FOnAddMessageActionsResponse struct.

FOnAddMessageActionsResponse

FieldTypeDescription
MessageActionTimetokenFStringTimetoken indicating when the message reaction was added.

Remove Message Reaction

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Remove a previously added reaction from a published message. Returns an empty response.

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString Channel = "randomChannel";
FString MessageTimeToken = "5610547826969050";
FString MessageTimeToken = "15610547826970050";

// Add the message reaction
PubnubSubsystem->RemoveMessageAction(Channel, MessageTimeToken, ActionTimeToken);

Returns

This method doesn't have any return value.

Get Message Reactions

Requires Message Persistence

This method requires that Message Persistence is enabled for your key in the Admin Portal. Read the support page on enabling add-on features on your keys.

Get a list of message reactions in a channel. Returns a list of actions sorted by the action's timetoken in ascending order.

Truncated response

Number of message reactions in the response may be truncated when internal limits are hit. If the response is truncated, a more property will be returned with additional parameters. Send iterative calls to Message Persistence adjusting the parameters to fetch more message reactions.

Method(s)

Response variants

You can also call the GetMessageActions_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetMessageActionsResponse OnGetMessageActionsResponse;
OnGetMessageActionsResponse.BindDynamic(this, &AMyActor::OnGetMessageActionsResponse);

FString Channel = "randomChannel";
FString Start = "";
FString End = "";

show all 17 lines

Returns

This method returns the FOnGetMessageActionsResponse struct.

FOnGetMessageActionsResponse


FieldTypeDescription
StatusintHTTP code of the result of the operation.
MessageActionsTArray<FPubnubMessageActionData>&An array of FPubnubMessageActionData structs which are the message reactions sent on a given channel.

JSON Response

{
"status": 200,
"data": [{
"messageTimetoken": "17198286823798098",
"type": "reaction",
"uuid": "User1",
"value": "happy",
"actionTimetoken": "17198286996058878"
}]
}

History with Message Reactions

You can choose to return message reactions when fetching historical message. Refer to Fetch History for more details.

Last updated on