---
source_url: https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/features/users/presence
title: Presence
updated_at: 2026-05-25T05:44:17.135Z
---

> Documentation Index
> For a curated overview of PubNub documentation, see: https://www.pubnub.com/docs/llms.txt
> For the full list of all documentation pages, see: https://www.pubnub.com/docs/llms-full.txt


# Presence

Track which users are online and active in your chat app. Display user status (online, offline, active, away) and show when users were last active.

##### Usage in Blueprints and C++

You can use PubNub's functionality via Blueprints or directly in C++ code.

* In Blueprints, you can access PubNub from any Widget or Actor. Start by [initializing chat](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub-chat) using `InitChat` on `UPubnubChatSubsystem`. Afterwards, you can use the returned `UPubnubChat` object reference to call all Chat SDK functions.

:::warning Blueprint functions
The Blueprints provided in the documentation show how you can structure your application and may contain utility methods and elements like buttons that are not part of the Unreal Chat SDK and are meant to serve as guidance.
:::

* In C++, you can use UPubnubChatSubsystem as any other Game Instance Subsystem. #include "Kismet/GameplayStatics.h" #include "Engine/GameInstance.h" #include "PubnubChatSubsystem.h" // ACTION REQUIRED: Replace ASample_ChatSubsystem with name of your Actor class void ASample_ChatSubsystem::InitChatSample() { // Get PubnubChatSubsystem from GameInstance UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this); UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>(); // Initialize Chat - InitChat may fail under some conditions so make sure to check the Result for errors before using the Chat FPubnubChatInitChatResult InitChatResult = PubnubChatSubsystem->InitChat(TEXT("demo"), TEXT("demo"), TEXT("Player_001")); UPubnubChat* PubnubChat = InitChatResult.Chat; } Chat now allows you to call all Chat SDK functions, for example, Chat->GetChannel("my_channel").

:::note 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. 1User->WherePresentAsync(OnWherePresentResponseDelegate); You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubChatWherePresentResponseNative).
* Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly. 1FPubnubChatWherePresentResult Result = User->WherePresent();
:::

The Chat SDK provides two types of presence tracking:

| Type | Description | Data source |
| --- | --- | --- |
| [Channel presence](#channel-presence) | Real-time tracking of users subscribed to specific channels | [Presence API](https://www.pubnub.com/docs/sdks/javascript/api-reference/presence) |
| [Global presence](#global-presence) | App-wide activity tracking based on timestamps | [lastActiveTimestamp](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/user) property |

**Channel presence** provides real-time updates through the Presence API. Presence events are delivered automatically via the channel's `OnPresenceChanged` multicast delegate when the channel is connected.

**Global presence** uses the `lastActiveTimestamp` property on `User` objects. Configure the update interval (default: 10 minutes, minimum: 1 minute) during [initialization](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#input-parameters) with `storeUserActivityTimestamps`.

## Channel presence

These methods let you monitor who is subscribed to a given channel ("present" on that channel).

:::note Requires Presence
All channel presence methods in this section require that [Presence is enabled](https://youtu.be/i2yLIqmvFD0) for your app's keyset in the [Admin Portal](https://admin.pubnub.com/).
:::

You can retrieve similar information for presence with different methods by calling them on the `User`, `Channel`, or `Chat` object. Depending on the chosen method, you must provide a different input information set.

### Return channels where user is present

You can return a list of channels where a given user is present with:

* `WherePresent()` called on the `User` object
* `WherePresent()` called on the `Chat` object.

Both of these methods have the same name and give the same output. The only difference is that you call a given method either on the `Chat` or the `User` object. Depending on the object, you either have to specify the ID of the user whose presence you want to check or not because it's already known.

#### Method signature

* User->WherePresent() 1User->WherePresent();
* Chat->WherePresent() 1Chat->WherePresent(FString UserID);

| Parameter | Required in `User->WherePresent()` | Required in `Chat->WherePresent()` | Description |
| --- | --- | --- | --- |
| `UserID`Type: `FString`Default: n/a | No | Yes | [Unique identifier](https://www.pubnub.com/docs/general/setup/users-and-devices#user-id-usage) (up to 92 UTF-8 characters) of the user whose presence you want to check. |

##### Output

| Method | Return type | Description |
| --- | --- | --- |
| `User->WherePresent()` | `FPubnubChatWherePresentResult` | Contains `Result` (operation result) and `Channels` (`TArray<FString>`). |
| `Chat->WherePresent()` | `FPubnubChatWherePresentResult` | Contains `Result` (operation result) and `Channels` (`TArray<FString>`). |

#### Sample code

:::tip 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.
:::

Get a list of channels on which a user is present.

**WherePresent() (on the User object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
void WherePresentSample();

UFUNCTION()
void OnWherePresentResponse(const FPubnubChatWherePresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::WherePresentSample()
{
	// snippet.hide
	UPubnubChatUser* User = nullptr;
	// snippet.show

	// Assumes User is a valid UPubnubChatUser (e.g. from GetUser)

	// Callback for when the operation completes (returns channel IDs)
	FOnPubnubChatWherePresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatUser::OnWherePresentResponse);
	User->WherePresentAsync(Callback);
}

// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::OnWherePresentResponse(const FPubnubChatWherePresentResult& Result)
{
	if (Result.Result.Error) { return; }
	TArray<FString> Channels = Result.Channels;
}
```

**WherePresent() (on the Chat object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Presence")
void WherePresentSample();

UFUNCTION()
void OnWherePresentResponse(const FPubnubChatWherePresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::WherePresentSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// List channels where a user is present (e.g. which channels they are subscribed to — for "online" or "in channel" indicator)
	FOnPubnubChatWherePresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnWherePresentResponse);
	Chat->WherePresentAsync(TEXT("Player_001"), Callback);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnWherePresentResponse(const FPubnubChatWherePresentResult& Result)
{
	if (Result.Result.Error) { return; }
	for (const FString& ChannelID : Result.Channels)
	{
		/* e.g. show in "user's active channels" list */
	}
}
```

### Check user's channel presence

You can return information if the user is present on a specified channel with:

* `IsPresentOn()` called on the `User` object
* `IsPresent()` called on the `Channel` object.
* `IsPresent()` called on the `Chat` object.

All of these methods give the same output. The only difference is that you call a given method on the `User`, `Channel`, or `Chat` object. Depending on the object, you have to specify the ID of the user whose presence you want to check, the channel ID where you want to check user's presence, or both user and channel IDs.

#### Method signature

* User->IsPresentOn() 1User->IsPresentOn(FString ChannelID);
* Channel->IsPresent() 1Channel->IsPresent(FString UserID); Returns FPubnubChatIsPresentResult (contains Result with Error/ErrorMessage and IsPresent bool).
* Chat->IsPresent() 1Chat->IsPresent(FString UserID, FString ChannelID);

| Parameter | Required in the `User` object method | Required in the `Channel` object method | Required in the `Chat` object method | Description |
| --- | --- | --- | --- | --- |
| `UserID`Type: `FString`Default: n/a | No | Yes | Yes | [Unique ID](https://www.pubnub.com/docs/general/setup/users-and-devices) (up to 92 UTF-8 characters) of the user whose presence you want to check. |
| `ChannelID`Type: `FString`Default: n/a | Yes | No | Yes | Unique identifier of the channel where you want to check the user's presence. |

##### Output

| Method | Return type |
| --- | --- |
| `User->IsPresentOn()` | `FPubnubChatIsPresentResult` (contains `Result` with `Error`/`ErrorMessage` and `IsPresent` bool) |
| `Channel->IsPresent()` | `FPubnubChatIsPresentResult` (contains `Result` with `Error`/`ErrorMessage` and `IsPresent` bool) |
| `Chat->IsPresent()` | `FPubnubChatIsPresentResult` (contains `Result` with `Error`/`ErrorMessage` and `IsPresent` bool) |

#### Sample code

:::tip 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.
:::

Find out if a user is present on a channel.

**IsPresentOn() (on the User object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
void IsPresentOnSample();

UFUNCTION()
void OnIsPresentOnResponse(const FPubnubChatIsPresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::IsPresentOnSample()
{
	// snippet.hide
	UPubnubChatUser* User = nullptr;
	// snippet.show

	// Assumes User is a valid UPubnubChatUser (e.g. from GetUser)

	// Channel ID to check presence for
	FString ChannelID = TEXT("lobby-01");

	// Callback for when the operation completes (returns whether user is present)
	FOnPubnubChatIsPresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatUser::OnIsPresentOnResponse);
	User->IsPresentOnAsync(ChannelID, Callback);
}

// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::OnIsPresentOnResponse(const FPubnubChatIsPresentResult& Result)
{
	if (Result.Result.Error) { return; }
	bool bIsPresent = Result.IsPresent;
}
```

**IsPresent() (on the Channel object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatChannel")
void IsPresentSample();

UFUNCTION()
void OnIsPresentResponse(const FPubnubChatIsPresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::IsPresentSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// User ID to check for presence (subscribed) on this channel
	FString UserID = TEXT("user-abc123");

	// Callback for when the operation completes (returns whether user is present)
	FOnPubnubChatIsPresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatChannel::OnIsPresentResponse);
	Channel->IsPresentAsync(UserID, Callback);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnIsPresentResponse(const FPubnubChatIsPresentResult& Result)
{
	if (Result.Result.Error) { return; }
	bool bIsPresent = Result.IsPresent;
}
```

**IsPresent() (on the Chat object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Presence")
void IsPresentSample();

UFUNCTION()
void OnIsPresentResponse(const FPubnubChatIsPresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::IsPresentSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// Check if a user is present on a channel (e.g. "is this player in the lobby?")
	FOnPubnubChatIsPresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnIsPresentResponse);
	Chat->IsPresentAsync(TEXT("Player_001"), TEXT("Lobby_001"), Callback);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnIsPresentResponse(const FPubnubChatIsPresentResult& Result)
{
	if (Result.Result.Error) { return; }
	bool bUserIsPresent = Result.IsPresent;
}
```

### Return all users present on channel

You can return a list of users present on the given channel with:

* `WhoIsPresent()` called on the `Channel` object
* `WhoIsPresent()` called on the `Chat` object.

Both of these methods have the same name and give the same output. The only difference is that you call a given method either on the `Chat` or the `Channel` object. Depending on the object, you either have to specify the ID of the channel where you want to check all present users or not because it's already known.

#### Method signature

* Channel->WhoIsPresent() 1Channel->WhoIsPresent(int Limit = 1000, int Offset = 0);
* Chat->WhoIsPresent() 1Chat->WhoIsPresent(FString ChannelID, int Limit = 1000, int Offset = 0);

| Parameter | Required in the `Channel` object method | Required in the `Chat` object method | Description |
| --- | --- | --- | --- |
| `ChannelID`Type: `FString`Default: n/a | No | Yes | Unique identifier of the channel where you want to check the user's presence. |
| `Limit`Type: `int`Default: `1000` | No | No | Maximum number of user IDs to return. |
| `Offset`Type: `int`Default: `0` | No | No | Number of user IDs to skip for pagination. |

##### Output

| Method | Return type |
| --- | --- |
| `Channel->WhoIsPresent()` | `FPubnubChatWhoIsPresentResult` (contains `Result` and `Users` `TArray<FString>`) |
| `Chat->WhoIsPresent()` | `FPubnubChatWhoIsPresentResult` (contains `Result` and `Users` `TArray<FString>`) |

#### Sample code

:::tip 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.
:::

Get a list of users that are present on a channel.

**WhoIsPresent() (on the Channel object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatChannel")
void WhoIsPresentSample();

UFUNCTION()
void OnWhoIsPresentResponse(const FPubnubChatWhoIsPresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::WhoIsPresentSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// Callback for when the operation completes (returns list of user IDs present)
	FOnPubnubChatWhoIsPresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
	Callback.BindUObject(this, &ASample_ChatChannel::OnWhoIsPresentResponse);
	Channel->WhoIsPresentAsync(Callback);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnWhoIsPresentResponse(const FPubnubChatWhoIsPresentResult& Result)
{
	if (Result.Result.Error) { return; }
	TArray<FString> UserIDs = Result.Users;
}
```

**WhoIsPresent() (on the Chat object)**

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|Chat|Presence")
void WhoIsPresentSample();

UFUNCTION()
void OnWhoIsPresentResponse(const FPubnubChatWhoIsPresentResult& Result);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::WhoIsPresentSample()
{
	// snippet.hide
	UPubnubChat* Chat = nullptr;
	// snippet.show

	// Assumes Chat is a valid and initialized instance of UPubnubChat

	// List users currently present on a channel (e.g. "who is in this lobby" or online list)
	FOnPubnubChatWhoIsPresentResponseNative Callback;
	// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
	Callback.BindUObject(this, &ASample_Chat::OnWhoIsPresentResponse);
	Chat->WhoIsPresentAsync(TEXT("Lobby_001"), Callback, 100, 0);
}

// ACTION REQUIRED: Replace ASample_Chat with name of your Actor class
void ASample_Chat::OnWhoIsPresentResponse(const FPubnubChatWhoIsPresentResult& Result)
{
	if (Result.Result.Error) { return; }
	for (const FString& UserID : Result.Users)
	{
		/* e.g. show in "online in channel" list */
	}
}
```

### Get presence updates

Call `StreamPresence()` on a `Channel` object to start receiving real-time presence events (who joins or leaves the channel). Presence updates are delivered through the channel's `OnPresenceChanged` multicast delegate, which broadcasts a `TArray<FString>` of user IDs currently present on the channel. Call `StopStreamingPresence()` to stop receiving updates.

You can use this information to visually represent user availability in your chat app through statuses like `offline`, `online`, `active`, `away`, or any other.

#### Method signature

* Channel->StreamPresence() 1Channel->StreamPresence();
* Channel->StopStreamingPresence() 1Channel->StopStreamingPresence();

##### Output

| Method | Return type | Description |
| --- | --- | --- |
| `Channel->StreamPresence()` | `FPubnubChatOperationResult` | Contains `Error` (bool) and `ErrorMessage` (FString). Success if the presence listener was started. |
| `Channel->StopStreamingPresence()` | `FPubnubChatOperationResult` | Contains `Error` (bool) and `ErrorMessage` (FString). Success if the presence listener was stopped. |

##### Delegate

| Delegate | Parameter | Description |
| --- | --- | --- |
| `OnPresenceChanged` | `const TArray<FString>& UserIDs` | Broadcasts the list of user IDs currently present on the channel whenever the presence set changes. |

#### Sample code

Start streaming presence on the `support` channel, bind the delegate to log user presence changes, and stop streaming when done.

```cpp
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

FPubnubChatInitChatResult InitResult = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");
UPubnubChat* Chat = InitResult.Chat;

FPubnubChatChannelResult ChannelResult = Chat->GetChannel("support");
UPubnubChatChannel* Channel = ChannelResult.Channel;

// Bind the delegate to receive presence updates
Channel->OnPresenceChanged.AddDynamic(this, &AMyActor::OnPresenceUpdated);

// Start streaming presence
FPubnubChatOperationResult StreamResult = Channel->StreamPresence();

// ... later, stop streaming
FPubnubChatOperationResult StopResult = Channel->StopStreamingPresence();
```

### Other examples

#### Stream presence on a channel

###### Actor.h

```cpp
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatChannel")
void StreamPresenceSample();

void OnPresenceUpdated(const TArray<FString>& UserIDs);
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::StreamPresenceSample()
{
	// snippet.hide
	UPubnubChatChannel* Channel = nullptr;
	// snippet.show

	// Assumes Channel is a valid UPubnubChatChannel (e.g. from GetChannel)

	// Bind to receive presence updates (user IDs currently subscribed)
	Channel->OnPresenceChangedNative.AddUObject(this, &ASample_ChatChannel::OnPresenceUpdated);

	// Start streaming presence
	Channel->StreamPresenceAsync(nullptr);

	// When presence updates are no longer needed, stop streaming
	Channel->StopStreamingPresenceAsync(nullptr);
}

// ACTION REQUIRED: Replace ASample_ChatChannel with name of your Actor class
void ASample_ChatChannel::OnPresenceUpdated(const TArray<FString>& UserIDs)
{
	/* e.g. update "online users" list in channel UI */
}
```

## Global presence

The Chat SDK lets you configure your app to track the user's last online activity - this gives near real-time visibility into the availability of other chat members, allowing you to see whether someone is offline or available and reach out to them to start immediate communication.

Using this online activity information provided by the Unreal Chat SDK, you can later configure your app to display different statuses next to user profiles, like `offline`, `online`, `active`, `away` or any other.

This feature relies on the [lastActiveTimestamp](https://www.pubnub.com/docs/chat/unreal-chat-sdk/learn/chat-entities/user) property set in milliseconds on the `User` object. This property stands for the Unix timestamp (numeric value representing the number of seconds since January 1, 1970) for the last time the user was active in a chat app. To track this, you must explicitly state that when configuring your app during the [Unreal Chat SDK initialization](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub) by:

* Setting the `storeUserActivityTimestamps` parameter to `true`.
* Deciding how frequently a user's online activity will be updated by configuring the `storeUserActivityInterval` option - the default value is set to `600000` milliseconds (10 minutes) and the minimum value is `60000` milliseconds (1 minute).

If you set these options, you can track a user's global presence through the `IsActive()` method that relies on the above setup. If the user showed no online activity within the defined period of time, they are considered inactive.

### Check user's app presence

`IsActive()` is a method called on the `User` object that lets you check whether a user has recently been active in the chat app based on their last activity timestamp and a configured interval.

:::note Required configuration
To track the user's online activity, you must first configure the `StoreUserActivityTimestamps` and `StoreUserActivityInterval` parameters when [initializing the Unreal Chat SDK](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub).
:::

#### Method signature

##### C++ / Input parameters

```cpp
User->IsActive();
```

##### Blueprint

#### Output

| Type | Description |
| --- | --- |
| `bool` | Whether the user is active or not. |

#### Sample code

:::tip 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.
:::

Return the current chat user's data.

###### Actor.h

```cpp
// blueprint.khfx0thh
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
void IsActiveSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::IsActiveSample()
{
	// snippet.hide
	UPubnubChatUser* User = nullptr;
	// snippet.show

	// Assumes User is a valid UPubnubChatUser (e.g. from GetUser)

	// Check if user is active based on last-activity timestamp
	bool bIsActive = User->IsActive();
}
```

### Check user's last online activity

:::note Required configuration
To track the user's online activity, you must first configure the `StoreUserActivityTimestamps` and `StoreUserActivityInterval` parameters when [initializing the Chat SDK](https://www.pubnub.com/docs/chat/unreal-chat-sdk/build/configuration#initialize-pubnub).
:::

Let's assume you configured your app to track the user's online activity and update it every 2 minutes. You can retrieve information on the user's last online activity directly from the `User` object, convert it to a human-readable date (using external date and time libraries), and display it next to the user's profile in your chat app. Thanks to that, other app users will be able to see the last time the given user was online.

#### Method signature

##### C++ / Input parameters

```cpp
User->GetLastActiveTimestamp();
```

##### Blueprint

#### Output

| Type | Description |
| --- | --- |
| `FString` | A timestamp for the last time the user was active. |

#### Sample code

:::tip 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.
:::

Return the current chat user's data.

###### Actor.h

```cpp
// blueprint.xlavewc-
UFUNCTION(BlueprintCallable, Category = "PubnubChat|Samples|ChatUser")
void GetLastActiveTimestampSample();
```

###### Actor.cpp

```cpp
// ACTION REQUIRED: Replace ASample_ChatUser with name of your Actor class
void ASample_ChatUser::GetLastActiveTimestampSample()
{
	// snippet.hide
	UPubnubChatUser* User = nullptr;
	// snippet.show

	// Assumes User is a valid UPubnubChatUser (e.g. from GetUser)

	// Get last active timestamp (timetoken format) from local cache
	FString LastActiveTimetoken = User->GetLastActiveTimestamp();
}
```