UnityUnity V4 Message Actions API Reference for Realtime Apps

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 PubNub Storage independently or when they fetch original messages.


Requires Storage & Playback add-on XRequires that the Storage & Playback add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.

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

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesThe channel name.
    MessageTimetokenlongYesThe publish timetoken of a parent message.
    MessageAction MessageActionAddYesMessage Action Details :-
    ActionType: What feature this action represents -- max 15 characters.
    ActionValue: Details about the action -- max 40 characters.
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);
        }

});

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

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.

Requires Storage & Playback add-on XRequires that the Storage & Playback add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.

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

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

  1. ParameterTypeRequiredDescription
    ChannelstringYesThe channel name.
    MessageTimetokenlongYesThe publish timetoken of a parent message.
    ActionTimetokenlongYesThe publish timetoken of the action.
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);
        }
});

The RemoveMessageAction() operation returns a no actionable data.


Requires Storage & Playback add-on XRequires that the Storage & Playback add-on is enabled for your key. See this page on enabling add-on features on your keys:

http://www.pubnub.com/knowledge-base/discussion/644/how-do-i-enable-add-on-features-for-my-keys.

Get a list of message actions in a channel. Returns a list of actions in the response.

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

  1. 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..
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);
        }

});

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.
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.