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 action events on that channel. They can also fetch past message reactions from Message Persistence independently or when they fetch original messages.
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)
- Blueprint
- C++
PubnubSubsystem->AddMessageAction(
FString ChannelName,
FString MessageTimeToken,
EPubnubActionType ActionType,
FString Value,
FOnPubnubResponse OnAddMessageActionResponse
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelName | FString | Yes | The channel to publish the message reaction to. |
MessageTimeToken | FString | Yes | The timetoken of a published message to apply the reaction to. |
ActionType | EPubnubActionType | Yes | Enum action type. Available values:
|
Value | FString | Yes | A String describing the action to be added. |
OnAddMessageActionResponse | FOnPubnubResponse | Yes | The callback function used to handle the result. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChannelName = "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
FOnPubnubResponse OnAddMessageActionResponse;
OnAddMessageActionResponse.BindDynamic(this, &AMyActor::OnAddMessageActionResponse);
show all 18 linesReturns
This method doesn't have any return value.
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)
- Blueprint
- C++
PubnubSubsystem->RemoveMessageAction(
FString ChannelName,
FString MessageTimeToken,
FString ActionTimeToken
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelName | FString | Yes | The channel the message reaction was published to. |
MessageTimeToken | FString | Yes | The timetoken of a published message to delete the reaction of. |
ActionTimeToken | FString | Yes | The timetoken of the published action to delete. |
Basic Usage
#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();
FString ChannelName = "randomChannel";
FString MessageTimeToken = "5610547826969050";
FString MessageTimeToken = "15610547826970050";
// Add the message action
PubnubSubsystem->RemoveMessageAction(ChannelName, 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)
- Blueprint
- C++
PubnubSubsystem->GetMessageActions(
FString ChannelName,
FString Start,
FString End,
int SizeLimit,
FOnPubnubResponse OnGetMessageActionsResponse
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelName | FString | Yes | The channel the message reaction was published to. |
Start | FString | Optional | Previously-returned cursor bookmark for fetching the next page. Use "" if you don’t want to paginate with a start bookmark. |
End | FString | Optional | Previously-returned cursor bookmark for fetching the previous page. Ignored if you also supply the start parameter. Use "" if you don’t want to paginate with an end bookmark. |
SizeLimit | int | Optional | Number of objects to return in response. Available values: 1 - 100 . If you set 0 , the default value of 100 is used. |
OnGetMessageActionsResponse | FOnPubnubResponse | Yes | The callback function used to handle the result. |
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
FOnPubnubResponse OnGetMessageActionsResponse;
OnGetMessageActionsResponse.BindDynamic(this, &AMyActor::OnGetMessageActionsResponse);
FString ChannelName = "randomChannel";
FString Start = "";
FString End = "";
show all 17 linesReturns
{
"status": 200,
"data": [{
"messageTimetoken": "17198286823798098",
"type": "reaction",
"uuid": "User1",
"value": "happy",
"actionTimetoken": "17198286996058878"
}]
}
History with 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.
Returns all actions added on a given channel between the start and end message timetoken.
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)
- Blueprint
- C++
PubnubSubsystem->HistoryWithMessageActions(
FString ChannelName,
FString Start,
FString End,
int SizeLimit,
FOnPubnubResponse OnHistoryWithMessageActionsResponse
);
Parameter | Type | Required | Description |
---|---|---|---|
ChannelName | FString | Yes | The channel to fetch teh message reactions from. |
Start | FString | Optional | Start message timetoken. Can be "" meaning there is no lower limitation in time. |
End | FString | Optional | End message timetoken. Can be "" in which case the upper time limit is present moment. |
SizeLimit | int | Optional | Number of objects to return in response. Available values: 1 - 100 . If you set 0 , the default value of 100 is used. |
OnHistoryWithMessageActionsResponse | FOnPubnubResponse | Yes | The callback function used to handle the result. |
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
FOnPubnubResponse OnHistoryWithMessageActionsResponse;
OnHistoryWithMessageActionsResponse.BindDynamic(this, &AMyActor::OnHistoryWithMessageActionsResponse);
FString ChannelName = "randomChannel";
FString Start = "";
FString End = "";
show all 17 linesReturns
{
"status": 200,
"channels": {
"my_channel": [{
"message": {
"text": "\"\\\"message\\\"\"",
"type": "text"
},
"timetoken": "17198286823798098",
"actions": {
"reaction": {
"happy": [{
"uuid": "User1",
"actionTimetoken": "17198286996058878"
}]
show all 22 lines