Read receipts
Read receipts indicate if other channel members have received and viewed a message.
Required setup
Read Receipts feature is tightly coupled with the Unread Message Count feature. To receive message read receipts, you must know which message was last read by which user on a given channel. That's why, to implement the Read Receipts feature, you must first set the timetoken of the last message a user read on a given channel. Based on that, Unreal Chat SDK will map a user's last read message to a given message timetoken and let you show this mapping result in your chat app as read or unread.
Get read receipts
StreamReadReceipts()
lets you get a read confirmation status for messages you published on a channel.
When called, the method fetches the read status of the members, listens for new messages, and updates the read status accordingly. The read status is then passed as an event of the receipt
type to a callback function for further processing or display.
Not available for public chats
Read receipts are disabled in public chats. If you try implementing this feature in a public channel type, you'll get the Read receipts are not supported in Public chats
error.
Method signature
- Blueprint
- C++ / Input parameters
Channel->StreamReadReceipts(FOnPubnubChannelStreamReadReceiptsReceived ReadReceiptsCallback);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
ReadReceiptsCallback | FOnPubnubChannelStreamReadReceiptsReceived | Yes | n/a | Callback function passed as a parameter. It defines the custom behavior to be executed when receiving a read confirmation status on the joined channel. |
Output
Type | Description |
---|---|
UPubnubCallbackStop* | Object on which you can call Stop() to stop receiving updates. |
Basic Usage
Receive updates for read receipts on the support
channel.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
UPubnubChannel* Channel = Chat->GetChannel("support");
// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnPubnubChannelStreamReadReceiptsReceived ReadReceiptsUpdatesOnResponse;
ReadReceiptsUpdatesOnResponse.BindDynamic(this, &AMyActor::OnReadReceiptsResponseReceived);
show all 19 lines