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.
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);
| Parameter | Description |
|---|---|
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. |
IncludeType: FPubnubGetAllInclude | A list of property names to include in the response. |
LimitType: int | Number of objects to return. Default/Max: 100. |
FilterType: FString | Filter expression. Only matching objects are returned. See filtering. |
SortType: FPubnubGetAllSort | Sort by id, name, updated with asc/desc for sort direction (for example, {name: 'asc'}). |
PageNextType: FString | Cursor-based pagination. Use to retrieve the next page. |
PagePrevType: FString | Cursor-based pagination. Use to retrieve the previous page. Ignored if PageNext is provided. |
CountType: EPubnubTribool enum | Whether to include a total count of users in the response (default: not set). |
FPubnubGetAllInclude
| Field | Type | Description |
|---|---|---|
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
| Field | Type | Description |
|---|---|---|
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
ACTION REQUIRED before running the code.- C++
- Blueprint
Actor.h
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);
| Parameter | Description |
|---|---|
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. |
Include | List of property names to include in the response. |
Sample code
Reference code
ACTION REQUIRED before running the code.- C++
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:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- 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);
| Parameter | Description |
|---|---|
UserMetadataType: FPubnubUserData | The user metadata object to create. |
FOnSetUserMetadataResponse | The delegate for the operation's result. You can also use a native callback of the type FOnSetUserMetadataResponseNative to handle the result using a lambda. |
Include | List 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
ACTION REQUIRED before running the code.- C++
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);
| Parameter | Description |
|---|---|
OnRemoveUserMetadataResponse | The 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
ACTION REQUIRED before running the code.- C++
Actor.h
FilterFStringSortFPubnubGetAllSort{name: 'asc'}).PageNextFStringPagePrevFStringPageNext is provided.Sample code
Reference code
ACTION REQUIRED before running the code.- C++
- Blueprint
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);
| Parameter | Description |
|---|---|
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. |
Include | List of property names to include in the response. |
Sample code
Reference code
ACTION REQUIRED before running the code.- C++
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:
- Get the existing metadata and store it locally.
- Append the new custom metadata to the existing one.
- 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);
| Parameter | Description |
|---|---|
ChannelMetadataType: FPubnubChannelData | The channel metadata object to create. |
FOnSetChannelMetadataResponse | The delegate for the operation's result. You can also use a native callback of the type FOnSetChannelMetadataResponseNative to handle the result using a lambda. |
Include | List 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
ACTION REQUIRED before running the code.- C++
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);
| Parameter | Description |
|---|---|
OnRemoveChannelMetadataResponse | The 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
ACTION REQUIRED before running the code.- C++
Actor.h
FilterFStringSortFPubnubMembershipSortPageNextFStringPagePrevFStringPageNext is provided.FPubnubMembershipInclude
| Field Name | Type | Default Value | Description |
|---|---|---|---|
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 Name | Type | Description |
|---|---|---|
MembershipSort | TArray<FPubnubMembershipSingleSort> | Array of sort criteria used in Membership-related functions. Order matters (applied in sequence). |
FPubnubMembershipSingleSort
| Field Name | Type | Default | Description |
|---|---|---|---|
| SortType | EPubnubMembershipSortType | EPubnubMembershipSortType::PMST_ChannelID | Field to sort by in the Membership context |
| SortOrder | bool | false | Ascending when false, descending when true |
EPubnubMembershipSortType
| Enum Value | Display Name | Description |
|---|---|---|
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
ACTION REQUIRED before running the code.- C++
- Blueprint
Actor.h
Reference code
ACTION REQUIRED before running the code.Set memberships for a user with result
Actor.h
FilterFStringSortFPubnubMemberSortPageNextFStringPagePrevFStringPageNext is provided.FPubnubMemberInclude
| Field Name | Type | Default | Description |
|---|---|---|---|
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 Name | Type | Description |
|---|---|---|
MemberSort | TArray<FPubnubMemberSingleSort> | Array of sort criteria used in Member-related functions. Order matters (applied in sequence). |
FPubnubMemberSingleSort
| Field Name | Type | Default | Description |
|---|---|---|---|
| SortType | EPubnubMemberSortType | EPubnubMemberSortType::PMeST_UserID | Field to sort by in the Member context |
| SortOrder | bool | false | Ascending when false, descending when true |
EPubnubMemberSortType
| Enum Value | Display Name | Description |
|---|---|---|
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
ACTION REQUIRED before running the code.- C++
- Blueprint
Actor.h
Reference code
ACTION REQUIRED before running the code.