Manage user details
Retrieve user details from your app.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Chat->GetUserAsync(UserID, OnGetUserResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatUserResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatUserResult Result = Chat->GetUser(UserID);
Get user details
GetUser() returns data about a specific user, including all custom metadata by default.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Method signature
- C++ / Input parameters
- Blueprint
1Chat->GetUser(FString UserID)
| Parameter | Description |
|---|---|
UserID *Type: FString | Unique user identifier. |
Output
| Type | Description |
|---|---|
FPubnubChatUserResult | Returned object containing Result (FPubnubChatOperationResult) and User (UPubnubChatUser*). The user is nullptr if not found. |
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.
Fetch a user by ID asynchronously.
Get current user
GetCurrentUser() returns the current chat user.
Requires App Context
Enable App Context in the Admin Portal to store user data.
Method signature
- C++ / Input parameters
- Blueprint
1Chat->GetCurrentUser();
Output
| Type | Description |
|---|---|
UPubnubChatUser* | Returned User object. |
Sample code
Return the current chat user.
- C++
- Blueprint
1
Get user ID
GetUserID() returns the current chat user's ID.
Method signature
- C++ / Input parameters
- Blueprint
1User->GetUserID();
Output
| Type | Description |
|---|---|
FString | Returned user ID. |
Sample code
Return the current chat user's ID.
- C++
- Blueprint
1
Get user data
GetUserData() returns the current chat user's data.
Method signature
- C++ / Input parameters
- Blueprint
1User->GetUserData();
Output
| Type | Description |
|---|---|
FPubnubChatUserData | Returned user data from the local cache. |
Sample code
Return the current chat user's data.
- C++
- Blueprint
1