On this page

Manage user details

Retrieve user details from your app.

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.

    1Chat->GetUserAsync(UserID, OnGetUserResponseDelegate);

    You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (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

1Chat->GetUser(FString UserID)
* required
ParameterDescription
UserID *
Type: FString
Unique user identifier.

Output

TypeDescription
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.

Actor.h
1

Actor.cpp
1

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

1Chat->GetCurrentUser();

Output

TypeDescription
UPubnubChatUser*
Returned User object.

Sample code

Return the current chat user.

1

Get user ID

GetUserID() returns the current chat user's ID.

Method signature

1User->GetUserID();

Output

TypeDescription
FString
Returned user ID.

Sample code

Return the current chat user's ID.

1

Get user data

GetUserData() returns the current chat user's data.

Method signature

1User->GetUserData();

Output

TypeDescription
FPubnubChatUserData
Returned user data from the local cache.

Sample code

Return the current chat user's data.

1

Last updated on