App Context API for Unreal SDK Copy for LLM Open Markdown 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.
You can use PubNub's functionality via Blueprints or directly in C++ code.
In Blueprints, the SDK is managed by a subsystem. Start by calling the Pubnub Subsystem node, then use Create Pubnub Client to create a UPubnubClient instance.
In a C++ project, you have to add a dependency to PubnubLibrary:
In your IDE, navigate to Source/_{YourProject}_/_{YourProject}_.Build.cs and add a dependency to PubnubLibrary.
PrivateDependencyModuleNames . AddRange ( new string [ ] { "PubnubLibrary" } ) ;
Compile the code and run the project.
In C++, get the UPubnubSubsystem (a Game Instance Subsystem), then create a UPubnubClient with your configuration. PublishKey, SubscribeKey, and UserID are required.
PubnubClient exposes the PubNub SDK functions. For example, refer to Publish .
The SDK supports multiple UPubnubClient instances within the same game for different contexts such as different users or keysets. For more information, refer to Configuration .
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.
1 PubnubClient -> GetAllUserMetadataAsync ( OnGetAllUserMetadataResponse , Include , Limit , Filter , Sort , Page ) ;
You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the Native suffix (for example, FOnPubnubGetAllUserMetadataResponseNative).
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1 FPubnubGetAllUserMetadataResult Result = PubnubClient -> GetAllUserMetadata ( Include , Limit , Filter , Sort , Page ) ;
User
Retrieve user metadata in pages. The list includes the Custom object if requested.
Required keyset configuration To get all channel and user metadata, you must uncheck the
Disallow Get All Channel Metadata and
Disallow Get All User Metadata checkboxes in the App Context section of your keyset configuration in the
Admin Portal .
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.
1 2 FPubnubGetAllUserMetadataResult Result = PubnubClient -> GetAllUserMetadata ( 3 FPubnubGetAllInclude Include = FPubnubGetAllInclude ( ) , 4 int Limit = 100 , 5 FString Filter = "" , 6 FPubnubGetAllSort Sort = FPubnubGetAllSort ( ) , 7 FPubnubPage Page = FPubnubPage ( ) 8 ) ; 9
10 11 PubnubClient -> GetAllUserMetadataAsync ( 12 FOnPubnubGetAllUserMetadataResponse OnGetAllUserMetadataResponse , 13 FPubnubGetAllInclude Include = FPubnubGetAllInclude ( ) , 14 int Limit = 100 , 15 FString Filter = "" , 16 FPubnubGetAllSort Sort = FPubnubGetAllSort ( ) , 17 FPubnubPage Page = FPubnubPage ( ) 18 ) ; show all 18 lines
Include# A list of property names to include in the response.
Limit# Number of objects to return. Default/Max: 100.
Filter# Filter expression. Only matching objects are returned. See filtering.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
FPubnubGetAllInclude
Field Type Description IncludeCustomboolWhether to include the Custom object in the response. IncludeStatusboolWhether to include the Status field of the object. IncludeTypeboolWhether to include the Type field of the object. IncludeTotalCountboolWhether to include the total count.
FPubnubGetAllSort
Field Type Description GetAllSortTArray<FPubnubGetAllSingleSort>Array of sorts for the get all functions. The order matters, sorts are applied from the first index to the last.
FPubnubGetAllSingleSort
Field Name Type Default Description SortTypeEPubnubGetAllSortTypeEPubnubGetAllSortType::PGAST_IDProperty to sort by. SortOrderboolfalseAscending when false, descending when true.
EPubnubGetAllSortType
Enum Value Display Name Description PGAST_IDUserIDSort by ID PGAST_NameUserNameSort by name PGAST_UpdatedUserUpdatedSort by last update PGAST_StatusUserStatusSort by status PGAST_TypeUserTypeSort by type
Sample code
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Returns
Field Type Description ResultFPubnubOperationResultThe result of the operation. UsersDataTArray<FPubnubUserData>Array of FPubnubUserData structs which are the users with their associated User metadata. PageFPubnubPagePagination cursor (Next, Prev) for requesting the next or previous page. TotalCountintTotal number of users matching the request (when requested).
FPubnubPage
Field Type Description NextFStringCursor for forward pagination. Use in the next request to fetch the following page. PrevFStringCursor for backward pagination. Use in the next request to fetch the previous page. Ignored if Next is supplied.
FPubnubUserData
Field Type Description UserIDFStringUnique user identifier. Ignored during set operations. UserNameFStringDisplay name for the user. ExternalIDFStringUser's identifier in an external system. ProfileUrlFStringThe URL of the user's profile picture. EmailFStringThe user's email address. CustomFStringCustom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported. StatusFStringUser status. Max. 50 characters. TypeFStringUser type. Max. 50 characters. UpdatedFStringThe date when the user's metadata was last updated. ETagFStringInformation on the object's content fingerprint.
This method is available to use with the UserMetadata entity. For more information, refer to UserMetadata .
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)
1 UPubnubUserMetadataEntity * UserMetadataEntity = PubnubClient -> CreateUserMetadataEntity ( FString User ) ; 2
3 4 FPubnubUserMetadataResult Result = UserMetadataEntity -> GetUserMetadata ( 5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 6 ) ; 7
8 9 UserMetadataEntity -> GetUserMetadataAsync ( 10 FOnPubnubGetUserMetadataResponse OnGetUserMetadataResponse , 11 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 12 ) ;
Include# List of property names to include in the response.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Retrieve metadata for a user. You can include the Custom object.
Method(s)
1 2 FPubnubUserMetadataResult Result = PubnubClient -> GetUserMetadata ( 3 FString User , 4 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 5 ) ; 6
7 8 PubnubClient -> GetUserMetadataAsync ( 9 FString User , 10 FOnPubnubGetUserMetadataResponse OnGetUserMetadataResponse , 11 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 12 ) ;
* required
User* required # The metadata ID for which to retrieve the user object. Can't be empty.
Include# List of property names to include in the response.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
This method is available to use with the UserMetadata entity. For more information, refer to UserMetadata .
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:
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)
1 UPubnubUserMetadataEntity * UserMetadataEntity = PubnubClient -> CreateUserMetadataEntity ( FString User ) ; 2
3 4 FPubnubUserMetadataResult Result = UserMetadataEntity -> SetUserMetadata ( 5 FPubnubUserInputData UserMetadata , 6 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 7 ) ; 8
9 10 UserMetadataEntity -> SetUserMetadataAsync ( 11 FPubnubUserInputData UserMetadata , 12 FOnPubnubSetUserMetadataResponse OnSetUserMetadataResponse , 13 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 14 ) ;
* required
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
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
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. Use FPubnubUserInputData for the metadata payload (supports ForceSet fields for partial updates).
Method(s)
1 2 FPubnubUserMetadataResult Result = PubnubClient -> SetUserMetadata ( 3 FString User , 4 FPubnubUserInputData UserMetadata , 5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 6 ) ; 7
8 9 PubnubClient -> SetUserMetadataAsync ( 10 FString User , 11 FPubnubUserInputData UserMetadata , 12 FOnPubnubSetUserMetadataResponse OnSetUserMetadataResponse , 13 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 14 ) ;
* required
User* required # The metadata ID for which to set the user object. Can't be empty.
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 .
Used for set operations. Contains the same fields as FPubnubUserData (e.g. UserName, Email, Custom, etc.). When present, ForceSet-style fields control which properties are updated (partial updates).
Field Type Description IncludeCustomboolWhether to include the object's Custom field. IncludeStatusboolWhether to include the object's Status field. IncludeTypeboolWhether to include the object's Type field.
Returns
Sample code
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
This method is available to use with the UserMetadata entity. For more information, refer to UserMetadata .
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)
1 UPubnubUserMetadataEntity * UserMetadataEntity = PubnubClient -> CreateUserMetadataEntity ( FString User ) ; 2
3 4 FPubnubOperationResult Result = UserMetadataEntity -> RemoveUserMetadata ( ) ; 5
6 7 UserMetadataEntity -> RemoveUserMetadataAsync ( FOnPubnubRemoveUserMetadataResponse OnRemoveUserMetadataResponse ) ;
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Removes the metadata from a specified user UUID.
Method(s)
1 2 FPubnubOperationResult Result = PubnubClient -> RemoveUserMetadata ( FString User ) ; 3
4 5 PubnubClient -> RemoveUserMetadataAsync ( FString User , FOnPubnubRemoveUserMetadataResponse OnRemoveUserMetadataResponse ) ;
* required
User* required # The metadata ID to delete from the user object. Can't be empty.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Channel
Retrieve channel metadata in pages. The list includes the Custom object if requested.
Method(s)
Method variants You can also call the GetAllChannelMetadataRaw variant of this method which takes String values for Include and Sort instead of the FPubnubGetAllInclude and FPubnubGetAllSort structs.
1 2 FPubnubGetAllChannelMetadataResult Result = PubnubClient -> GetAllChannelMetadata ( 3 FPubnubGetAllInclude Include = FPubnubGetAllInclude ( ) , 4 int Limit = 100 , 5 FString Filter = "" , 6 FPubnubGetAllSort Sort = FPubnubGetAllSort ( ) , 7 FPubnubPage Page = FPubnubPage ( ) 8 ) ; 9
10 11 PubnubClient -> GetAllChannelMetadataAsync ( 12 FOnPubnubGetAllChannelMetadataResponse OnGetAllChannelMetadataResponse , 13 FPubnubGetAllInclude Include = FPubnubGetAllInclude ( ) , 14 int Limit = 100 , 15 FString Filter = "" , 16 FPubnubGetAllSort Sort = FPubnubGetAllSort ( ) , 17 FPubnubPage Page = FPubnubPage ( ) 18 ) ; show all 18 lines
Include# A list of property names to include in the response.
Limit# Number of objects to return. Default/Max: 100.
Filter# Filter expression. Only matching objects are returned. See filtering.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
Sample code
Returns
Field Type Description ResultFPubnubOperationResultThe result of the operation. ChannelsDataTArray<FPubnubChannelData>Array of FPubnubChannelData structs which are the channels with their associated metadata. PageFPubnubPagePagination cursor (Next, Prev) for requesting the next or previous page. TotalCountintTotal number of channels matching the request (when requested).
FPubnubChannelData
Field Type Description ChannelIDFStringID of the channel. ChannelNameFStringName of the channel. DescriptionFStringAdditional description of the channel. CustomFStringCustom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported. StatusFStringChannel status. Max 50 characters. TypeFStringChannel type. Max 50 characters. UpdatedFStringThe date when the channel's metadata was last updated. ETagFStringVersion identifier of the channel's metadata.
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
This method is available to use with the ChannelMetadata entity. For more information, refer to ChannelMetadata .
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)
1 UPubnubChannelMetadataEntity * ChannelMetadataEntity = PubnubClient -> CreateChannelMetadataEntity ( FString Channel ) ; 2
3 4 FPubnubChannelMetadataResult Result = ChannelMetadataEntity -> GetChannelMetadata ( 5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 6 ) ; 7
8 9 ChannelMetadataEntity -> GetChannelMetadataAsync ( 10 FOnPubnubGetChannelMetadataResponse OnGetChannelMetadataResponse , 11 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 12 ) ;
* required
Include# List of property names to include in the response.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Retrieve metadata for a channel. You can include the Custom object.
Method(s)
1 2 FPubnubChannelMetadataResult Result = PubnubClient -> GetChannelMetadata ( 3 FString Channel , 4 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 5 ) ; 6
7 8 PubnubClient -> GetChannelMetadataAsync ( 9 FString Channel , 10 FOnPubnubGetChannelMetadataResponse OnGetChannelMetadataResponse , 11 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 12 ) ;
* required
Channel* required # The channel ID for which to retrieve the channel object. Can't be empty.
Include# List of property names to include in the response.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
This method is available to use with the ChannelMetadata entity. For more information, refer to ChannelMetadata .
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:
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)
1 UPubnubChannelMetadataEntity * ChannelMetadataEntity = PubnubClient -> CreateChannelMetadataEntity ( FString Channel ) ; 2
3 4 FPubnubChannelMetadataResult Result = ChannelMetadataEntity -> SetChannelMetadata ( 5 FPubnubChannelInputData ChannelMetadata , 6 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 7 ) ; 8
9 10 ChannelMetadataEntity -> SetChannelMetadataAsync ( 11 FPubnubChannelInputData ChannelMetadata , 12 FOnPubnubSetChannelMetadataResponse OnSetChannelMetadataResponse , 13 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 14 ) ;
* required
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
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
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. Use FPubnubChannelInputData for the metadata payload (supports ForceSet fields for partial updates).
Method(s)
1 2 FPubnubChannelMetadataResult Result = PubnubClient -> SetChannelMetadata ( 3 FString Channel , 4 FPubnubChannelInputData ChannelMetadata , 5 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 6 ) ; 7
8 9 PubnubClient -> SetChannelMetadataAsync ( 10 FString Channel , 11 FPubnubChannelInputData ChannelMetadata , 12 FOnPubnubSetChannelMetadataResponse OnSetChannelMetadataResponse , 13 FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude ( ) 14 ) ;
* required
Channel* required # The metadata ID for which to set the channel object. Can't be empty.
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 .
Used for set operations. Contains the same fields as FPubnubChannelData (e.g. ChannelName, Description, Custom, etc.). When present, ForceSet-style fields control which properties are updated (partial updates).
Returns
Sample code
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Actor.h
Actor.cpp
This method is available to use with the ChannelMetadata entity. For more information, refer to ChannelMetadata .
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)
1 UPubnubChannelMetadataEntity * ChannelMetadataEntity = PubnubClient -> CreateChannelMetadataEntity ( FString Channel ) ; 2
3 4 FPubnubOperationResult Result = ChannelMetadataEntity -> RemoveChannelMetadata ( ) ; 5
6 7 ChannelMetadataEntity -> RemoveChannelMetadataAsync ( FOnPubnubRemoveChannelMetadataResponse OnRemoveChannelMetadataResponse ) ;
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Removes the metadata from a specified channel.
Method(s)
1 2 FPubnubOperationResult Result = PubnubClient -> RemoveChannelMetadata ( FString Channel ) ; 3
4 5 PubnubClient -> RemoveChannelMetadataAsync ( FString Channel , FOnPubnubRemoveChannelMetadataResponse OnRemoveChannelMetadataResponse ) ;
* required
Channel* required # The metadata ID to delete from the channel object. Can't be empty.
Sample code
Returns
Other examples
Actor.h
Actor.cpp
Actor.h
Actor.cpp
Channel memberships
Get channel memberships
The method returns a list of channel memberships for a user. This method doesn't return a user's subscriptions.
Method(s)
Method variants You can also call the GetMembershipsRaw variant of this method which takes String values for Include and Sort instead of the FPubnubMembershipInclude and FPubnubMembershipSort structs.
1 2 FPubnubMembershipsResult Result = PubnubClient -> GetMemberships ( 3 FString User , 4 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 5 int Limit = 100 , 6 FString Filter = "" , 7 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 8 FPubnubPage Page = FPubnubPage ( ) 9 ) ; 10
11 12 PubnubClient -> GetMembershipsAsync ( 13 FString User , 14 FOnPubnubGetMembershipsResponse OnGetMembershipsResponse , 15 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 16 int Limit = 100 , 17 FString Filter = "" , 18 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 19 FPubnubPage Page = FPubnubPage ( ) 20 ) ; show all 20 lines
* required
User* required # The user UUID for whom to retrieve memberships.
OnGetMembershipsResponse# More Include# List of property names to include in the response.
Limit# Number of objects to return. Default/Max: 100.
Filter# Filter expression. Only matching objects are returned. See filtering.
Sort# Key-value pair of a property to sort by, and a sort direction.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
FPubnubMembershipInclude
Field Name Type Default Value Description IncludeCustombool false Whether to include the membership's Custom field. IncludeStatusbool false Whether to include the membership's Status field. IncludeTypebool false Whether to include the membership's Type field. IncludeChannelbool false Whether to include the membership's Channel data field (in form of FPubnubChannelData). IncludeChannelCustombool false Whether to include the membership's Channel Custom field. IncludeChannelStatusbool false Whether to include the membership's Channel Status field IncludeChannelTypebool false Whether to include the membership's Channel Type field IncludeTotalCountbool false Whether to include the total count of memberships
FPubnubMembershipSort
Field Name Type Description MembershipSortTArray<FPubnubMembershipSingleSort>Array of sort criteria used in Membership-related functions. Order matters (applied in sequence).
FPubnubMembershipSingleSort
Field Name Type Default Description SortType EPubnubMembershipSortTypeEPubnubMembershipSortType::PMST_ChannelIDField to sort by in the Membership context SortOrder bool false Ascending when false, descending when true
EPubnubMembershipSortType
Enum Value Display Name Description PMST_ChannelIDChannelIDSort by Channel ID PMST_ChannelNameChannelNameSort by Channel Name PMST_ChannelUpdatedChannelUpdatedSort by last update to the Channel PMST_ChannelStatusChannelStatusSort by Channel Status PMST_ChannelTypeChannelTypeSort by Channel Type PMST_UpdatedUpdatedSort by Membership update timestamp PMST_StatusStatusSort by Membership status PMST_TypeTypeSort by Membership type
Sample code
Returns
FPubnubMembershipsResult
Field Type Description ResultFPubnubOperationResultThe result of the operation. MembershipsDataTArray<FPubnubMembershipData>Array of FPubnubMembershipData structs which are the memberships. PageFPubnubPagePagination cursor (Next, Prev) for requesting the next or previous page. TotalCountintTotal number of memberships matching the request (when requested).
FOnPubnubGetMembershipsResponse
FPubnubMembershipData
Field Type Description ChannelFPubnubChannelDataContains channel metadata, including unique channel identifier and other relevant information. CustomFStringCustom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn’t supported. StatusFStringStatus of the membership. Max 50 characters. TypeFStringType of the membership. Max 50 characters. UpdatedFStringThe date when the channel's membership was last updated. ETagFStringVersion identifier of the membership metadata.
FOnPubnubGetMembershipsResponseNative
Other examples
Get memberships for a user with settings
Actor.h
Actor.cpp
Get memberships for a user with lambda
Actor.h
Actor.cpp
Get memberships for a user with raw
Actor.h
Actor.cpp
Set channel memberships
Set channel memberships for a User.
Method(s)
1 2 FPubnubMembershipsResult Result = PubnubClient -> SetMemberships ( 3 FString User , 4 TArray < FPubnubMembershipInputData > Channels , 5 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 6 int Limit = 100 , 7 FString Filter = "" , 8 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 9 FPubnubPage Page = FPubnubPage ( ) 10 ) ; 11
12 13 PubnubClient -> SetMembershipsAsync ( 14 FString User , 15 TArray < FPubnubMembershipInputData > Channels , 16 FOnPubnubSetMembershipsResponse OnSetMembershipsResponse , 17 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 18 int Limit = 100 , 19 FString Filter = "" , 20 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 21 FPubnubPage Page = FPubnubPage ( ) 22 ) ; show all 22 lines
* required
User* required # The user UUID to add/update the memberships. Can't be empty.
Channels* required # The array of channel memberships to add/update. Can't be empty.
OnSetMembershipsResponse# More Include# List of property names to include in the response.
Limit# The maximum number of memberships to return.
Filter# The filter to apply to the memberships.
Sort# The sort order to apply to the memberships.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
API limits To learn about the maximum length of parameters used to set user metadata, refer to REST API docs .
Field Type Description ChannelFStringThe channel ID to add/update the membership. Can't be empty. CustomFStringThe custom data to add/update the membership. StatusFStringThe status of the membership. TypeFStringThe type of the membership.
Returns
FOnPubnubSetMembershipsResponse
FOnPubnubSetMembershipsResponseNative
Sample code
API limits To learn about the maximum length of parameters used to set channel membership metadata, refer to REST API docs .
Other examples
Set memberships for a user with result
Actor.h
Actor.cpp
Set memberships for a user with lambda
Actor.h
Actor.cpp
Set memberships for a user with raw
Actor.h
Actor.cpp
Remove Channel Memberships
Remove channel memberships for a user.
Method(s)
1 2 FPubnubMembershipsResult Result = PubnubClient -> RemoveMemberships ( 3 FString User , 4 TArray < FString > Channels , 5 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 6 int Limit = 100 , 7 FString Filter = "" , 8 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 9 FPubnubPage Page = FPubnubPage ( ) 10 ) ; 11
12 13 PubnubClient -> RemoveMembershipsAsync ( 14 FString User , 15 TArray < FString > Channels , 16 FOnPubnubRemoveMembershipsResponse OnRemoveMembershipsResponse , 17 FPubnubMembershipInclude Include = FPubnubMembershipInclude ( ) , 18 int Limit = 100 , 19 FString Filter = "" , 20 FPubnubMembershipSort Sort = FPubnubMembershipSort ( ) , 21 FPubnubPage Page = FPubnubPage ( ) 22 ) ; show all 22 lines
* required
User* required # The user UUID to remove the memberships. Can't be empty.
Channels* required # The array of channel IDs to remove the memberships. Can't be empty.
OnRemoveMembershipsResponse# More Include# List of property names to include in the response.
Limit# The maximum number of memberships to return.
Filter# The filter to apply to the memberships.
Sort# The sort order to apply to the memberships.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
API limits To learn about the maximum length of parameters used to set user metadata, refer to REST API docs .
Sample code
Returns
FOnPubnubRemoveMembershipsResponse
FOnPubnubRemoveMembershipsResponseNative
Other examples
Remove memberships for a user with result
Actor.h
Actor.cpp
Remove memberships for a user with lambda
Actor.h
Actor.cpp
Remove memberships for a user with raw
Actor.h
Actor.cpp
Channel members
Get channel members
The method returns a list of members in a channel. The list will include user metadata for members that have additional metadata stored in the database.
Method(s)
Method variants You can also call the GetChannelMembersRaw variant of this method which takes String values for Include, and Sort instead of the FPubnubMemberInclude and FPubnubMemberSort structs.
1 2 FPubnubChannelMembersResult Result = PubnubClient -> GetChannelMembers ( 3 FString Channel , 4 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 5 int Limit = 100 , 6 FString Filter = "" , 7 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 8 FPubnubPage Page = FPubnubPage ( ) 9 ) ; 10
11 12 PubnubClient -> GetChannelMembersAsync ( 13 FString Channel , 14 FOnPubnubGetChannelMembersResponse OnGetChannelMembersResponse , 15 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 16 int Limit = 100 , 17 FString Filter = "" , 18 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 19 FPubnubPage Page = FPubnubPage ( ) 20 ) ; show all 20 lines
* required
Channel* required # The Channel ID for which to retrieve members.
OnGetChannelMembersResponse# More Include# List of property names to include in the response.
Limit# Number of objects to return. Default/Max: 100.
Filter# Expression used to filter the results. Check online documentation to see exact filter formulas.
Sort# Key-value pair of a property to sort by, and a sort direction.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
FPubnubMemberInclude
Field Name Type Default Description IncludeCustombool false Whether to include the member's Custom field IncludeStatusbool false Whether to include the member's Status field IncludeTypebool false Whether to include the member's Type field IncludeUserbool false Whether to include the member's User data (in form of FPubnubUserData) IncludeUserCustombool false Whether to include the member's User Custom field IncludeUserStatusbool false Whether to include the member's User Status field IncludeUserTypebool false Whether to include the member's User Type field IncludeTotalCountbool false Whether to include the total count of paginated records
FPubnubMemberSort
Field Name Type Description MemberSortTArray<FPubnubMemberSingleSort>Array of sort criteria used in Member-related functions. Order matters (applied in sequence).
FPubnubMemberSingleSort
Field Name Type Default Description SortType EPubnubMemberSortTypeEPubnubMemberSortType::PMeST_UserIDField to sort by in the Member context SortOrder bool false Ascending when false, descending when true
EPubnubMemberSortType
Enum Value Display Name Description PMeST_UserIDUserIDSort by Member's User ID PMeST_UserNameUserNameSort by Member's User Name PMeST_UserUpdatedUserUpdatedSort by when the User was updated PMeST_UserStatusUserStatusSort by User Status PMeST_UserTypeUserTypeSort by User Type PMeST_UpdatedUpdatedSort by Member record update timestamp PMeST_StatusStatusSort by Member Status PMeST_TypeTypeSort by Member Type
Sample code
Returns
FPubnubChannelMembersResult
Field Type Description ResultFPubnubOperationResultThe result of the operation. MembersDataTArray<FPubnubChannelMemberData>Array of FPubnubChannelMemberData structs which are the members of the channel. PageFPubnubPagePagination cursor (Next, Prev) for requesting the next or previous page. TotalCountintTotal number of members matching the request (when requested).
FOnPubnubGetChannelMembersResponse
FPubnubChannelMemberData
Field Type Description UserFPubnubUserDataContains user metadata, including unique user identifier and other relevant information. CustomFStringCustom JSON values. Can be strings, numbers, or booleans. Filtering by Custom isn't supported. StatusFStringStatus of the member. Max 50 characters. TypeFStringType of the member. Max 50 characters. UpdatedFStringThe date when the channel's member was last updated. ETagFStringVersion identifier of the member metadata.
FOnPubnubGetChannelMembersResponseNative
Other examples
Get channel members with settings
Actor.h
Actor.cpp
Get channel members with lambda
Actor.h
Actor.cpp
Get channel members raw
Actor.h
Actor.cpp
Set channel members
This method sets members in a channel.
Method(s)
1 2 FPubnubChannelMembersResult Result = PubnubClient -> SetChannelMembers ( 3 FString Channel , 4 TArray < FPubnubChannelMemberInputData > Users , 5 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 6 int Limit = 100 , 7 FString Filter = "" , 8 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 9 FPubnubPage Page = FPubnubPage ( ) 10 ) ; 11
12 13 PubnubClient -> SetChannelMembersAsync ( 14 FString Channel , 15 TArray < FPubnubChannelMemberInputData > Users , 16 FOnPubnubSetChannelMembersResponse OnSetChannelMembersResponse , 17 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 18 int Limit = 100 , 19 FString Filter = "" , 20 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 21 FPubnubPage Page = FPubnubPage ( ) 22 ) ; show all 22 lines
* required
Channel* required # The channel ID to add/update the members. Can't be empty.
Users* required # The array of channel members to add/update. Can't be empty.
OnSetChannelMembersResponse# More Include# List of property names to include in the response.
Limit# The maximum number of members to return.
Filter# The filter to apply to the members.
Sort# The sort order to apply to the members.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
API limits To learn about the maximum length of parameters used to set user metadata, refer to REST API docs .
Field Type Description UserFStringThe user UUID to add/update the membership. Can't be empty. CustomFStringThe custom data to add/update the membership. StatusFStringThe status of the membership. TypeFStringThe type of the membership.
Returns
FOnPubnubSetChannelMembersResponse
FOnPubnubSetChannelMembersResponseNative
Sample code
API limits To learn about the maximum length of parameters used to set channel members metadata, refer to REST API docs .
Other examples
Set channel members with result
Actor.h
Actor.cpp
Set channel members with lambda
Actor.h
Actor.cpp
Set channel members raw
Actor.h
Actor.cpp
Remove Channel Members
Remove members from a channel.
Method(s)
1 2 FPubnubChannelMembersResult Result = PubnubClient -> RemoveChannelMembers ( 3 FString Channel , 4 TArray < FString > Users , 5 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 6 int Limit = 100 , 7 FString Filter = "" , 8 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 9 FPubnubPage Page = FPubnubPage ( ) 10 ) ; 11
12 13 PubnubClient -> RemoveChannelMembersAsync ( 14 FString Channel , 15 TArray < FString > Users , 16 FOnPubnubRemoveChannelMembersResponse OnRemoveChannelMembersResponse , 17 FPubnubMemberInclude Include = FPubnubMemberInclude ( ) , 18 int Limit = 100 , 19 FString Filter = "" , 20 FPubnubMemberSort Sort = FPubnubMemberSort ( ) , 21 FPubnubPage Page = FPubnubPage ( ) 22 ) ; show all 22 lines
* required
Channel* required # The channel ID to remove the members. Can't be empty.
Users* required # The array of user UUIDs to remove from the channel. Can't be empty.
OnRemoveChannelMembersResponse# More Include# List of property names to include in the response.
Limit# The maximum number of members to return.
Filter# The filter to apply to the members.
Sort# The sort order to apply to the members.
Page# Cursor-based pagination. Use Page.Next and Page.Prev to request the next or previous page.
Sample code
Returns
FOnPubnubRemoveChannelMembersResponse
FOnPubnubRemoveChannelMembersResponseNative
Other examples
Remove channel members with result
Actor.h
Actor.cpp
Remove channel members with lambda
Actor.h
Actor.cpp
Remove channel members raw
Actor.h
Actor.cpp
Complete example
ASample_AppContextFull.h
ASample_AppContextFull.cpp