Manage user updates
Update user details and receive real-time update events.
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.1User->UpdateAsync(UpdateData, OnOperationResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (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 aUserobject (no ID needed)UpdateUser()- call on aChatobject (requires user ID)
Method signature
- C++ / Input parameters
- Blueprint
-
User->Update()1User->Update(FPubnubChatUpdateUserInputData UpdateUserData); -
Chat->UpdateUser()1Chat->UpdateUser(
2 FString UserID,
3 FPubnubChatUpdateUserInputData UpdateUserData
4);
| Parameter | Required in User->Update() | Required in Chat->UpdateUser() | Description |
|---|---|---|---|
UserIDType: FStringDefault: n/a | No | Yes | Unique user identifier. |
UpdateUserDataDefault: n/a | Yes | Yes | User data fields to update and optional ForceSet flags. |
FPubnubChatUpdateUserInputData
| Parameter | Description |
|---|---|
UserNameType: FStringDefault: "" | Display name for the user (must not be empty or consist only of whitespace characters). |
ExternalIDType: FStringDefault: "" | User's identifier in an external system. You can use it to match id with a similar identifier from an external database. |
ProfileUrlType: FStringDefault: "" | URL of the user's profile picture. |
EmailType: FStringDefault: "" | User's email address. |
CustomType: FStringDefault: "" | 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. |
StatusType: FStringDefault: "" | 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. |
TypeType: FStringDefault: "" | 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. |
ForceSetUserNameType: boolDefault: false | When true, replaces the field value entirely instead of merging with the existing value. |
ForceSetExternalIDType: boolDefault: false | When true, replaces the field value entirely instead of merging. |
ForceSetProfileUrlType: boolDefault: false | When true, replaces the field value entirely instead of merging. |
ForceSetEmailType: boolDefault: false | When true, replaces the field value entirely instead of merging. |
ForceSetCustomType: boolDefault: false | When true, replaces the field value entirely instead of merging. |
ForceSetStatusType: boolDefault: false | When true, replaces the field value entirely instead of merging. |
ForceSetTypeType: boolDefault: 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
| Type | Description |
|---|---|
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.
UpdateUser()
- C++
- Blueprint
1
Get user updates
Receive updates when User objects are edited or removed:
StreamUpdates()- monitors a single userStreamUpdatesOn()- 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
- C++ / Input parameters
- Blueprint
-
StreamUpdates()1User->StreamUpdates(); -
StreamUpdatesOn()(static)1UPubnubChatUser::StreamUpdatesOn(
2 const TArray<UPubnubChatUser*>& Users
3); -
StopStreamingUpdates()1User->StopStreamingUpdates();
| Parameter | Description |
|---|---|
UsersType: 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. |
Output
| Method | Return type | Description |
|---|---|---|
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
- C++
- Blueprint
1