Message Reactions API for PubNub Go 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 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 the added action in the response.
Method(s)
To Add a Message Reaction you can use the following method(s) in the Go SDK:
pn.AddMessageAction().
Channel(string).
MessageTimetoken(string).
Action(pubnub.MessageAction).
Execute()
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
MessageTimetoken | string | Yes | The publish timetoken of a parent message. |
Action | pubnub.MessageAction | Yes | Message Reaction Details :-ActionType : What feature this action represents -- max 15 characters. ActionValue : Details about the action -- max 40 characters. |
Basic Usage
ma := pubnub.MessageAction{
ActionType: "reaction",
ActionValue: "smiley_face",
}
res, status, err := pn.AddMessageAction()
.Channel("my-channel")
.MessageTimetoken("15698453963258802")
.Action(ma)
.Execute()
Returns
The AddMessageAction()
operation returns a PNAddMessageActionsResponse
which contains the following parameters:
Property Name | Type | Description |
---|---|---|
Data | PNMessageActionsResponse | Details of type PNMessageActionsResponse are here |
PNMessageActionsResponse
Property Name | Type | Description |
---|---|---|
ActionType | string | What feature this action represents. |
ActionValue | string | Details about the action. |
ActionTimetoken | string | The timetoken when the action was added. |
MessageTimetoken | string | The timetoken of the parent message. |
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 Go SDK:
pn.RemoveMessageAction().
Channel(string).
MessageTimetoken(string).
ActionTimetoken(string).
Execute()
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
MessageTimetoken | string | Yes | The publish timetoken of a parent message. |
ActionTimetoken | string | Yes | The publish timetoken of the action. |
Basic Usage
res, status, err := pn.RemoveMessageAction()
.Channel("my-channel")
.MessageTimetoken("15698453963258802")
.ActionTimetoken("15698453963258812")
.Execute()
Returns
The RemoveMessageAction()
operation returns a PNRemoveMessageActionsResponse
which contains the following parameters:
Property Name | Type | Description |
---|---|---|
Data | interface | Returns an empty interface. |
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 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 Message Persistence adjusting the parameters to fetch more message actions.
Method(s)
To Get Message Reactions you can use the following method(s) in the Go SDK:
pn.GetMessageActions().
Channel(string).
Start(string).
End(string).
Limit(int).
Execute()
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
Start | string | Optional | Action timetoken denoting the start of the range requested (return values will be less than start). |
End | string | Optional | Action timetoken denoting the end of the range requested (return values will be greater than or equal to end). |
Limit | int | Optional | Number of actions to return in response.. |
Basic Usage
res, status, err := pn.GetMessageActions()
.Channel("my-channel")
.Start("15698453963258812")
.End("15698453963258811")
.Execute()
Returns
The GetMessageActions()
operation returns a PNGetMessageActionsResponse
which contains the following parameters:
Property Name | Type | Description |
---|---|---|
Data | []PNMessageActionsResponse | Details of type PNMessageActionsResponse are here |
More | PNGetMessageActionsMore | Details of type PNGetMessageActionsMore are here |
PNGetMessageActionsMore
Property Name | Type | Description |
---|---|---|
URL | string | The URL of the next set of results. |
Start | string | The start param for the next set of results. |
End | string | The end param for the next set of results. |
Limit | int | The limit for the next set of results. |