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)
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
MessageTimetoken | long | Yes | The publish timetoken of a parent message. |
MessageAction | MessageActionAdd | Yes | Message 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 linesReturns
The AddMessageActions()
operation returns a PNMessageActionsResult
which contains the following parameters:
PNMessageActionsResult
Property Name | Type | Description |
---|---|---|
ActionType | string | What feature this action represents. |
ActionValue | string | Details about the action. |
ActionTimetoken | long | The timetoken when the action was added. |
MessageTimetoken | long | The timetoken of the parent message. |
UUID | string | The 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)
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
MessageTimetoken | long | Yes | The publish timetoken of a parent message. |
ActionTimetoken | long | Yes | The 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)
Parameter | Type | Required | Description |
---|---|---|---|
Channel | string | Yes | The channel name. |
Start | long | Optional | Action timetoken denoting the start of the range requested (return values will be less than start). |
End | long | 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
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 linesReturns
The GetMessageActions()
operation returns a PNGetMessageActionsResult
which contains the following parameters:
Property Name | Type | Description |
---|---|---|
Data | List<PNMessageActionsResult > | Details of type PNMessageActionsResult are here |
More | PNGetMessageActionsMore | Details of type PNGetMessageActionsMore are here |
PNGetMessageActionsMore
Property Name | Type | Description |
---|---|---|
URL | string | The URL for the next set of results. |
Start | long | The start param for the next set of results. |
End | long | The end param for the next set of results. |
Limit | int | The limit for the next set of results. |