On this page

Manage user updates

Update user details and receive real-time update events.

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.

    1User->UpdateAsync(UpdateData, OnOperationResponseDelegate);

    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 = User->Update(UpdateData);
Requires App Context

Enable App Context in the Admin Portal to store user data.

Update user details

Edit user metadata with Update() or UpdateUser().

  • Update() - call on a User object (no ID needed)
  • UpdateUser() - call on a Chat object (requires user ID)

Method signature

  • User->Update()

    1User->Update(FPubnubChatUpdateUserInputData UpdateUserData);
  • Chat->UpdateUser()

    1Chat->UpdateUser(
    2 FString UserID,
    3 FPubnubChatUpdateUserInputData UpdateUserData
    4);
ParameterRequired in User->Update()Required in Chat->UpdateUser()Description
UserID
Type: FString
Default:
n/a
No
Yes
Unique user identifier.
UpdateUserDataYes
Yes
User data fields to update and optional ForceSet flags.

FPubnubChatUpdateUserInputData


* required
ParameterDescription
UserName
Type: FString
Default:
""
Display name for the user (must not be empty or consist only of whitespace characters).
ExternalID
Type: FString
Default:
""
User's identifier in an external system. You can use it to match id with a similar identifier from an external database.
ProfileUrl
Type: FString
Default:
""
URL of the user's profile picture.
Email
Type: FString
Default:
""
User's email address.
Custom
Type: FString
Default:
""
JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported. Filtering App Context data through the custom property is not recommended in SDKs.
Status
Type: FString
Default:
""
Tag that lets you categorize your app users by their current state. The tag choice is entirely up to you and depends on your use case. For example, you can use status to mark users in your chat app as invited, active, or archived.
Type
Type: FString
Default:
""
Tag that lets you categorize your app users by their functional roles. The tag choice is entirely up to you and depends on your use case. For example, you can use type to group users by their roles in your app, such as moderator, player, or support-agent.
ForceSetUserName
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging with the existing value.
ForceSetExternalID
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
ForceSetProfileUrl
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
ForceSetEmail
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
ForceSetCustom
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
ForceSetStatus
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
ForceSetType
Type: bool
Default:
false
When true, replaces the field value entirely instead of merging.
API limits

To learn about the maximum length of parameters used to set user metadata, refer to REST API docs.

Output

TypeDescription
FPubnubChatOperationResult
Returned object containing Error (bool) and ErrorMessage (FString). The same User object is updated in-place via the local cache.

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.

Update user metadata asynchronously.

Actor.h
1

Actor.cpp
1

  • UpdateUser()
1

Get user updates

Receive updates when User objects are edited or removed:

  • StreamUpdates() - monitors a single user
  • StreamUpdatesOn() - monitors multiple users (static method)
  • StopStreamingUpdates() - stops monitoring

To receive updates, bind to the OnUpdated and OnDeleted multicast delegates on the User object before calling StreamUpdates(). Updates are delivered through the delegates rather than callback parameters.

Delegate behavior
  • OnUpdated - fires when user metadata changes (params: FString UserID, FPubnubChatUserData UserData)
  • OnDeleted - fires when the user is deleted on the server (no params)

Method signature

  • StreamUpdates()

    1User->StreamUpdates();
  • StreamUpdatesOn() (static)

    1UPubnubChatUser::StreamUpdatesOn(
    2 const TArray<UPubnubChatUser*>& Users
    3);
  • StopStreamingUpdates()

    1User->StopStreamingUpdates();
* required
ParameterDescription
Users
Type: TArray<UPubnubChatUser*>
Default:
n/a
Array of User objects for which you want to get updates. Each user must have its delegates bound before calling this method.
icon

Handle the response


Output

MethodReturn typeDescription
StreamUpdates()
FPubnubChatOperationResult
Operation result with Error (bool) and ErrorMessage (FString). No-op if already streaming.
StreamUpdatesOn()
FPubnubChatOperationResult
Combined operation result from calling StreamUpdates() on each user.
StopStreamingUpdates()
FPubnubChatOperationResult
Operation result. No-op if not streaming.

Sample code

1

Last updated on