On this page

App Context API for Unreal SDK

App Context provides easy-to-use, serverless storage for user and channel data you need to build innovative, reliable, scalable applications. Use App Context to easily store metadata about your application users and channels, and their membership associations, without the need to stand up your own databases.

PubNub also triggers events when object data is changed: set, updated, or removed from the database. At the same time, making a request to set the same data that already exist, doesn't trigger any event. Clients can receive these events in real time and update their front-end application accordingly.

icon

Usage in Blueprints and C++

User

Get metadata for all users

Retrieve user metadata in pages. The list includes the Custom object if requested.

Method(s)

Method variants

You can also call the GetAllUserMetadataRaw variant of this method which takes String values for Include and Sort instead of the FPubnubGetAllInclude and FPubnubGetAllSort structs.

1PubnubSubsystem->GetAllUserMetadata(
2 FOnGetAllUserMetadataResponse OnGetAllUserMetadataResponse,
3 FPubnubGetAllInclude Include = FPubnubGetAllInclude(),
4 int Limit = 100,
5 FString Filter = "",
6 FPubnubGetAllSort Sort = FPubnubGetAllSort(),
7 FString PageNext = "",
8 FString PagePrev = ""
9);
* required
ParameterDescription
OnGetAllUserMetadataResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetAllUserMetadataResponseNative to handle the result using a lambda.
IncludeA list of property names to include in the response.
Limit
Type: int
Number of objects to return. Default/Max: 100.
Filter
Type: FString
Filter expression. Only matching objects are returned. See filtering.
SortSort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}).
PageNext
Type: FString
Cursor-based pagination. Use to retrieve the next page.
PagePrev
Type: FString
Cursor-based pagination. Use to retrieve the previous page. Ignored if PageNext is provided.
Count
Type: EPubnubTribool enum
Whether to include a total count of users in the response (default: not set).

FPubnubGetAllInclude

FieldTypeDescription
IncludeCustom
bool
Whether to include the Custom object in the response.
IncludeStatus
bool
Whether to include the membership Status field.
IncludeType
bool
Whether to include the membership Type field.
IncludeTotalCount
bool
Whether to include the total count.

FPubnubGetAllSort

FieldTypeDescription
GetAllSort
TArray<FPubnubGetAllSingleSort>
Array of sorts for Membership related function. The order matters, sorts will be applied from the first index to the last.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


icon

Available in entities

UserMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Retrieve metadata for a user. You can include the Custom object.

Method(s)

1UPubnubUserMetadataEntity* UserMetadataEntity = PubnubSubsystem->CreateUserMetadataEntity("user-id");
2
3UserMetadataEntity->GetUserMetadata(
4 FOnGetUserMetadataResponse OnGetUserMetadataResponse,
5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
6);
* required
ParameterDescription
OnGetUserMetadataResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetUserMetadataResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


UserMetadata.

icon

Available in entities

UserMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a User in the database, optionally including the custom data object for each.

Method(s)

1UPubnubUserMetadataEntity* UserMetadataEntity = PubnubSubsystem->CreateUserMetadataEntity("user-id");
2
3UserMetadataEntity->SetUserMetadata(
4 FPubnubUserData UserMetadata,
5 FOnSetUserMetadataResponse OnSetUserMetadataResponse,
6 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
7);
* required
ParameterDescription
UserMetadataThe user metadata object to create.
FOnSetUserMetadataResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnSetUserMetadataResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
API limits

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

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


UserMetadata.

icon

Available in entities

UserMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Removes the metadata from a specified user UUID.

Method(s)

1UPubnubUserMetadataEntity* UserMetadataEntity = PubnubSubsystem->CreateUserMetadataEntity("user-id");
2
3UserMetadataEntity->RemoveUserMetadata(
4 FOnRemoveUserMetadataResponse OnRemoveUserMetadataResponse
5);
* required
ParameterDescription
OnRemoveUserMetadataResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnRemoveUserMetadataResponseNative to handle the result using a lambda.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


Number of objects to return. Default/Max: 100.
Filter
Type: FString
Filter expression. Only matching objects are returned. See filtering.
SortSort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}).
PageNext
Type: FString
Cursor-based pagination. Use to retrieve the next page.
PagePrev
Type: FString
Cursor-based pagination. Use to retrieve the previous page. Ignored if PageNext is provided.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


ChannelMetadata.

icon

Available in entities

ChannelMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Retrieve metadata for a channel. You can include the Custom object.

Method(s)

1UPubnubChannelMetadataEntity* ChannelMetadataEntity = PubnubSubsystem->CreateChannelMetadataEntity("channel-id");
2
3ChannelMetadataEntity->GetChannelMetadata(
4 FOnGetChannelMetadataResponse OnGetChannelMetadataResponse,
5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
6);
* required
ParameterDescription
OnGetChannelMetadataResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetChannelMetadataResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


ChannelMetadata.

icon

Available in entities

ChannelMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Unsupported partial updates of custom metadata

The value of the custom metadata parameter sent in this method always overwrites the value stored on PubNub servers. If you want to add new custom data to an existing one, you must:

  1. Get the existing metadata and store it locally.
  2. Append the new custom metadata to the existing one.
  3. Set the entire updated custom object.

Set metadata for a channel in the database, optionally including the custom data object for each.

Method(s)

1UPubnubChannelMetadataEntity* ChannelMetadataEntity = PubnubSubsystem->CreateChannelMetadataEntity("channel-id");
2
3ChannelMetadataEntity->SetChannelMetadata(
4 FPubnubChannelData ChannelMetadata,
5 FOnSetChannelMetadataResponse OnSetChannelMetadataResponse,
6 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
7);
* required
ParameterDescription
ChannelMetadataThe channel metadata object to create.
FOnSetChannelMetadataResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnSetChannelMetadataResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
API limits

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

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


ChannelMetadata.

icon

Available in entities

ChannelMetadata

Requires App Context add-on

This method requires the App Context add-on enabled for your key in the Admin Portal.

Removes the metadata from a specified channel.

Method(s)

1UPubnubChannelMetadataEntity* ChannelMetadataEntity = PubnubSubsystem->CreateChannelMetadataEntity("channel-id");
2
3ChannelMetadataEntity->RemoveChannelMetadata(
4 FOnRemoveChannelMetadataResponse OnRemoveChannelMetadataResponse
5);
* required
ParameterDescription
OnRemoveChannelMetadataResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnRemoveChannelMetadataResponseNative to handle the result using a lambda.

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


Number of objects to return. Default/Max: 100.
Filter
Type: FString
Filter expression. Only matching objects are returned. See filtering.
SortKey-value pair of a property to sort by, and a sort direction.
PageNext
Type: FString
Cursor-based pagination. Use to retrieve the next page.
PagePrev
Type: FString
Cursor-based pagination. Use to retrieve the previous page. Ignored if PageNext is provided.

FPubnubMembershipInclude

Field NameTypeDefault ValueDescription
IncludeCustom
bool
false
Whether to include the membership's Custom field.
IncludeStatus
bool
false
Whether to include the membership's Status field.
IncludeType
bool
false
Whether to include the membership's Type field.
IncludeChannel
bool
false
Whether to include the membership's Channel data field (in form of FPubnubChannelData).
IncludeChannelCustom
bool
false
Whether to include the membership's Channel Custom field.
IncludeChannelStatus
bool
false
Whether to include the membership's Channel Status field
IncludeChannelType
bool
false
Whether to include the membership's Channel Type field
IncludeTotalCount
bool
false
Whether to include the total count of memberships

FPubnubMembershipSort

Field NameTypeDescription
MembershipSort
TArray<FPubnubMembershipSingleSort>
Array of sort criteria used in Membership-related functions. Order matters (applied in sequence).

FPubnubMembershipSingleSort

Field NameTypeDefaultDescription
SortType
EPubnubMembershipSortType
EPubnubMembershipSortType::PMST_ChannelID
Field to sort by in the Membership context
SortOrder
bool
false
Ascending when false, descending when true

EPubnubMembershipSortType

Enum ValueDisplay NameDescription
PMST_ChannelID
ChannelID
Sort by Channel ID
PMST_ChannelName
ChannelName
Sort by Channel Name
PMST_ChannelUpdated
ChannelUpdated
Sort by last update to the Channel
PMST_ChannelStatus
ChannelStatus
Sort by Channel Status
PMST_ChannelType
ChannelType
Sort by Channel Type
PMST_Updated
Updated
Sort by Membership update timestamp
PMST_Status
Status
Sort by Membership status
PMST_Type
Type
Sort by Membership type

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


Other examples
Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Set memberships for a user with result
Actor.h
Number of objects to return. Default/Max: 100.
Filter
Type: FString
Expression used to filter the results. Check online documentation to see exact filter formulas.
SortKey-value pair of a property to sort by, and a sort direction.
PageNext
Type: FString
A string to retrieve the next page of results (if applicable).
PagePrev
Type: FString
A string to retrieve the previous page of results (if applicable). Ignored if PageNext is provided.

FPubnubMemberInclude

Field NameTypeDefaultDescription
IncludeCustom
bool
false
Whether to include the member's Custom field
IncludeStatus
bool
false
Whether to include the member's Status field
IncludeType
bool
false
Whether to include the member's Type field
IncludeUUID
bool
false
Whether to include the member's User data (FPubnubUUIDMetadata)
IncludeUUIDCustom
bool
false
Whether to include the member's User Custom field
IncludeUUIDStatus
bool
false
Whether to include the member's User Status field
IncludeUUIDType
bool
false
Whether to include the member's User Type field
IncludeTotalCount
bool
false
Whether to include the total count of paginated records

FPubnubMemberSort

Field NameTypeDescription
MemberSort
TArray<FPubnubMemberSingleSort>
Array of sort criteria used in Member-related functions. Order matters (applied in sequence).

FPubnubMemberSingleSort

Field NameTypeDefaultDescription
SortType
EPubnubMemberSortType
EPubnubMemberSortType::PMeST_UserID
Field to sort by in the Member context
SortOrder
bool
false
Ascending when false, descending when true

EPubnubMemberSortType

Enum ValueDisplay NameDescription
PMeST_UserID
UserID
Sort by Member's User ID
PMeST_UserName
UserName
Sort by Member's User Name
PMeST_UserUpdated
UserUpdated
Sort by when the User was updated
PMeST_UserStatus
UserStatus
Sort by User Status
PMeST_UserType
UserType
Sort by User Type
PMeST_Updated
Updated
Sort by Member record update timestamp
PMeST_Status
Status
Sort by Member Status
PMeST_Type
Type
Sort by Member Type

Sample code

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.

Actor.h


Other examples
Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Set channel members with result
Actor.h
Sep 11, 2025