C#C# 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 C# V4 SDK:

  1. ParameterTypeRequiredDescription
    ChannelstringYesSpecifies channel name to publish message actions to.
    MessageTimetokenlongYesTimestamp when the actual message was created the message action belongs to.
    ActionPNMessageActionYesSpecify the action you want to publish of type PNMessageAction.

    ParameterTypeRequiredDescription
    TypestringYesMessage action’s type.
    ValuestringYesMessage action’s value.
pubnub.AddMessageAction()
    .Channel("my_channel")
    .MessageTimetoken(5610547826969050)
    .Action(new PNMessageAction { Type = "reaction", Value = "smiley_face" })
    .Execute(new PNAddMessageActionResultExt((result, status) =>
    {
        //result is of type PNAddMessageActionResult.
    }));
{
    "MessageTimetoken":15610547826969050, 
    "ActionTimetoken":15610547826970050, 
    "Action":{
        "type":"reaction", 
        "value":"smiley_face"
    },
    "Uuid":"user-456"
}

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 C# V4 SDK:

  1. ParameterTypeRequiredDescription
    ChannelstringYesSpecifies channel name to publish message actions to.
    MessageTimetokenlongYesPublish timetoken of the original message
    ActionTimetokenlongYesPublish timetoken of the message action to be removed.
    UuidstringYesUUID of the message.
pubnub.RemoveMessageAction()
    .Channel("my_channel")
    .MessageTimetoken(15701761818730000)
    .ActionTimetoken(15701775691010000)
    .Uuid("mytestuuid")
    .Execute(new PNRemoveMessageActionResultExt((result, status) =>
    {
        //empty result of type PNRemoveMessageActionResult.
    }));

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 C# V4 SDK:

  1. ParameterTypeRequiredDefaultsDescription
    ChannelstringYesThe channel name.
    StartlongOptionalMessage Action timetoken denoting the start of the range requested (return values will be less than start).
    EndlongOptionalMessage Action timetoken denoting the end of the range requested (return values will be greater than or equal to end).
    LimitintOptional100Specifies the number of actions to return in response.
    Default/Maximum is 100.
pubnub.GetMessageActions()
    .Channel("my_channel")
    .Execute(new PNGetMessageActionsResultExt((result, status) =>
    {
        //result is of type PNGetMessageActionsResult.
    }));
{
"MessageActions":
    [{
    "MessageTimetoken":15610547826969050,
    "Action":{
        "type":"reaction",
        "value":"smiley_face"
    },
    "Uuid":"pn-5903a053-592c-4a1e-8bfd-81d92c962968",
    "ActionTimetoken":15717253483027900
    }],
"More": {
        "Start": 15610547826970050, 
        "End": 15645905639093361, 
        "Limit": 2
    }
}