Message Reactions API for PubNub C# 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.
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 an action on a published message
. Returns PNAddMessageActionResult
in the response.
Method(s)
To Add a Message Reaction you can use the following method(s) in the C# SDK:
pubnub.AddMessageAction()
.Channel(string)
.MessageTimetoken(long)
.Action(PNMessageAction)
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | Specifies channel name to publish message reactions to. |
MessageTimetoken | long | Yes | Timestamp when the actual message was created the message reaction belongs to. |
Action | PNMessageAction | Yes | Specify the action you want to publish of type PNMessageAction . |
PNMessageAction
Parameter | Type | Required | Description |
---|---|---|---|
Type | string | Yes | Message reaction's type . |
Value | string | Yes | Message reaction's value . |
Basic Usage
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.
}));
Returns
{
"MessageTimetoken":15610547826969050,
"ActionTimetoken":15610547826970050,
"Action":{
"type":"reaction",
"value":"smiley_face"
},
"Uuid":"user-456"
}
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 action on a published message
. Returns an empty response.
Method(s)
To Remove a Message Reaction you can use the following method(s) in the C# SDK:
pubnub.RemoveMessageAction()
.Channel(string)
.MessageTimetoken(long)
.ActionTimetoken(long)
.Uuid(string)
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | Specifies channel name to publish message reactions to. |
MessageTimetoken | long | Yes | Publish timetoken of the original message |
ActionTimetoken | long | Yes | Publish timetoken of the message reaction to be removed. |
Uuid | string | Yes | UUID of the message . |