On this page

Read receipts

Required setup

Read Receipts requires Unread Message Count. First, set the last read timetoken for each user on a channel.

Read receipts show if channel members have viewed a message.

The SDK provides two complementary methods for working with read receipts:

  • FetchReadReceipts() — one-time paginated fetch. Returns the last-read timetoken for each member. Use this for initial load or on-demand checks. Supports any number of channel members.
  • StreamReadReceipts() — real-time subscription. Delivers updates via the channel's OnReadReceiptReceived delegate as individual users update their read position. Each update contains a single user's last-read timetoken, not a full member list.
icon

Usage in Blueprints and C++


Asynchronous and synchronous method execution

Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.

  • Asynchronous methods (Async suffix) return void and take an optional delegate parameter that fires when the operation completes.

    1Channel->StreamReadReceiptsAsync(OnStreamReadReceiptsResponseDelegate);

    You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubChatOperationResponseNative).

  • Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.

    1FPubnubChatOperationResult Result = Channel->StreamReadReceipts();

Get read receipts

StreamReadReceipts() provides read status for messages on a channel. The method fetches member read status and listens for updates. Read receipt data is delivered via the channel's OnReadReceiptReceived multicast delegate—bind it before calling StreamReadReceipts().

Not available for public chats

Read receipts are disabled in public chats.

Method signature

1Channel->StreamReadReceipts();

Output

TypeDescription
FPubnubChatOperationResult
Contains Error and ErrorMessage; use to check if the operation succeeded.

To stop receiving read receipt updates, call StopStreamingReadReceipts() on the channel.

Fetch read receipts

Retrieve a snapshot of the current read status for all channel members with FetchReadReceipts(). Unlike StreamReadReceipts(), this is a one-time fetch that does not subscribe to updates.

Method signature

1Channel->FetchReadReceipts(
2 int Limit = 0,
3 FString Filter = "",
4 FPubnubMemberSort Sort = FPubnubMemberSort(),
5 FPubnubPage Page = FPubnubPage()
6);
* required
ParameterDescription
Limit
Type: int
Default:
0
Number of member read receipts to return. Pass 0 to use the server default.
Filter
Type: FString
Default:
""
Expression used to filter the results. The filter language is defined here.
Sort
Type: FPubnubMemberSort
Default:
n/a
Struct defining the property to sort by and sort direction.
Page
Type: FPubnubPage
Default:
n/a
Object used for pagination to define which previous or next result page you want to fetch.
 → Next
Type: FString
Default:
n/a
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination.
 → Prev
Type: FString
Default:
n/a
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination. Ignored if Next is supplied.

Output

ParameterDescription
FPubnubChatFetchReadReceiptsResult
Type: struct
Returned object containing Result, ReadReceipts, Page, and Total.
 → Result
Type: FPubnubChatOperationResult
Contains Error and ErrorMessage for operation status.
 → ReadReceipts
Type: TArray<FPubnubChatReadReceipt>
Array of read receipts for channel members.
   → UserID
Type: FString
Unique identifier of the user who generated this read receipt.
   → LastReadTimetoken
Type: FString
Timetoken of the last message read by this user. Messages before this timetoken are considered read.
 → Page
Type: FPubnubPage
Object used for pagination.
 → Total
Type: int
Total number of member read receipts.

Sample code

Fetch the current read receipt status for all members of the support channel.

1FPubnubChatFetchReadReceiptsResult Result = Channel->FetchReadReceipts();
2if (!Result.Result.Error)
3{
4 for (const FPubnubChatReadReceipt& Receipt : Result.ReadReceipts)
5 {
6 UE_LOG(LogTemp, Log, TEXT("User %s last read: %s"), *Receipt.UserID, *Receipt.LastReadTimetoken);
7 }
8}

Sample code

Reference code

This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.

Stream read receipt events on a channel.

Actor.h
1

Actor.cpp
1

Last updated on