Message Actions API for PubNub Unity 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 actions from Message Persistence independently or when they fetch original messages.

Add Message Action

Requires Message Persistence add-on

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

Description

Add an action on a published message. Returns PNAddMessageActionResult in the response.

Method(s)

To Add a Message Action you can use the following method(s) in the Unity V4 SDK:

pn.AddMessageActions().Channel(string).MessageAction(MessageActionAdd).MessageTimetoken(long)
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
MessageTimetokenlongYesThe publish timetoken of a parent message.
MessageActionMessageActionAddYesMessage Action Details :-ActionType: What feature this action represents -- max 15 characters. ActionValue: Details about the action -- max 40 characters.

Basic Usage

MessageActionAdd add = new MessageActionAdd();
add.ActionType = "reaction";
add.ActionValue = "smiley_face";

pubnub.AddMessageActions().Channel("message_actions_channel").MessageAction(add).MessageTimetoken(15742286266685611).Async((result, status) => {
if (!status.Error) {
//PNMessageActionsResult
Debug.Log("result.ActionTimetoken: " + result.ActionTimetoken);
Debug.Log("result.ActionType: " + result.ActionType);
Debug.Log("result.ActionValue: " + result.ActionValue);
Debug.Log("result.MessageTimetoken: " + result.MessageTimetoken);
Debug.Log("result.UUID: " + result.UUID);
} else {
Debug.Log(status.Error);
Debug.Log(status.ErrorData.Info);
show all 18 lines

Returns

The AddMessageActions() operation returns a PNMessageActionsResult which contains the following parameters:

PNMessageActionsResult

Property NameTypeDescription
ActionTypestringWhat feature this action represents.
ActionValuestringDetails about the action.
ActionTimetokenlongThe timetoken when the action was added.
MessageTimetokenlongThe timetoken of the parent message.
UUIDstringThe UUID of the sender.

Remove Message Action

Requires Message Persistence add-on

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

Description

Remove a peviously added action on a published message. Returns an empty response.

Method(s)

To Remove a Message Action you can use the following method(s) in the Unity V4 SDK:

pn.RemoveMessageActions().ActionTimetoken(long).Channel(string).MessageTimetoken(long)
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
MessageTimetokenlongYesThe publish timetoken of a parent message.
ActionTimetokenlongYesThe publish timetoken of the action.

Basic Usage

pubnub.RemoveMessageActions().ActionTimetoken(15742286266685611).Channel("message_actions_channel").MessageTimetoken(15742286266685611).Async((result, status) => {
if (!status.Error) {
//PNRemoveMessageActionsResult
} else {
Debug.Log(status.Error);
Debug.Log(status.ErrorData.Info);
}
});

Returns

The RemoveMessageAction() operation returns a no actionable data.

Get Message Actions

Requires Message Persistence add-on

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

Description

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

Truncated response

Number of message actions 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 storage adjusting the parameters to fetch more message actions.

Method(s)

To Get Message Actions you can use the following method(s) in the Unity V4 SDK:

pn.GetMessageActions().Channel(string).Start(long).End(long).Limit(int)
ParameterTypeRequiredDescription
ChannelstringYesThe channel name.
StartlongOptionalAction timetoken denoting the start of the range requested (return values will be less than start).
EndlongOptionalAction timetoken denoting the end of the range requested (return values will be greater than or equal to end).
LimitintOptionalNumber of actions to return in response..

Basic Usage

pubnub.GetMessageActions().Channel("message_actions_channel").Start(15742286266685612).End(15742286266685611).Async((result, status) => {
if (!status.Error) {
//PNGetMessageActionsResult
if((result.Data != null) && (result.Data.Count >0)){
Debug.Log("result.ActionTimetoken: " + result.Data[0].ActionTimetoken);
Debug.Log("result.ActionType: " + result.Data[0].ActionType);
Debug.Log("result.ActionValue: " + result.Data[0].ActionValue);
Debug.Log("result.MessageTimetoken: " + result.Data[0].MessageTimetoken);
Debug.Log("result.UUID: " + result.Data[0].UUID);
}
} else {
Debug.Log(status.Error);
Debug.Log(status.ErrorData.Info);
}

show all 16 lines

Returns

The GetMessageActions() operation returns a PNGetMessageActionsResult which contains the following parameters:

Property NameTypeDescription
DataList<PNMessageActionsResult>Details of type PNMessageActionsResult are here
MorePNGetMessageActionsMoreDetails of type PNGetMessageActionsMore are here

PNGetMessageActionsMore

Property NameTypeDescription
URLstringThe URL for the next set of results.
StartlongThe start param for the next set of results.
EndlongThe end param for the next set of results.
LimitintThe limit for the next set of results.
Last updated on