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

Returns a paginated list of User Metadata objects, optionally including the custom data object for each.

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.

PubnubSubsystem->GetAllUserMetadata(
FOnGetAllUserMetadataResponse OnGetAllUserMetadataResponse,
FPubnubGetAllInclude Include = FPubnubGetAllInclude(),
int Limit = 100,
FString Filter = "",
FPubnubGetAllSort Sort = FPubnubGetAllSort(),
FString PageNext = "",
FString PagePrev = ""
);
* 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
The maximum number of results to return (default: 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. For example: {name: 'asc'}
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.
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 membership Custom field.
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



Actor.cpp



Other examples
Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Get metadata for all users with additional settings
Actor.h

Actor.cpp

Get metadata for all users with all includes
Actor.h

Actor.cpp

Get metadata for all users with lambda
Actor.h

Actor.cpp

Get metadata for all users raw
Actor.h

Actor.cpp

Returns

This function is void, but the delegate returns the FOnGetAllUserMetadataResponse struct.

FOnGetAllUserMetadataResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
UsersData
const TArray<FPubnubUserData>&
Aa array of FPubnubUserData structs which are the users with their associated User metadata.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FPubnubUserData

FieldTypeDescription
UserID
FString
Unique user identifier. If not supplied, then the current user's User is used.
UserName
FString
Display name for the user.
ExternalID
FString
User's identifier in an external system.
ProfileUrl
FString
The URL of the user's profile picture.
Email
FString
The user's email address.
Custom
FString
JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported.
Status
FString
User status. Max. 50 characters.
Type
FString
User type. Max. 50 characters.
Updated
FString
The date when the user's metadata was last updated.
ETag
FString
Information on the object's content fingerprint.

FOnGetAllUserMetadataResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
UsersData
const TArray<FPubnubUserData>&
Aa array of FPubnubUserData structs which are the users with their associated User metadata.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Get user metadata

Returns metadata for the specified User, optionally including the custom data object for each.

Method(s)

PubnubSubsystem->GetUserMetadata(
FString User,
FOnGetUserMetadataResponse OnGetUserMetadataResponse,
FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
);
* required
ParameterDescription
User *
Type: FString
The metadata ID for which to retrieve the user object. Can't be empty.
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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnGetUserMetadataResponse struct.

FOnGetUserMetadataResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
UserData
FPubnubUserData
Aa instance of FPubnubUserData struct which is the user with their associated User metadata.
FOnGetUserMetadataResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
UserData
const FPubnubUserData&
Aa instance of FPubnubUserData struct which is the user with their associated User metadata.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Get metadata for a user with all includes
Actor.h

Actor.cpp

Get metadata for a user with lambda
Actor.h

Actor.cpp

Get metadata for a user raw
Actor.h

Actor.cpp

Set user metadata with additional settings
Actor.h

Actor.cpp

Set user metadata with result struct
Actor.h

Actor.cpp

Remove user metadata with result struct
Actor.h

Actor.cpp

Set user metadata

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)

PubnubSubsystem->SetUserMetadata(
FString User,
FPubnubUserData UserMetadata,
FOnSetUserMetadataResponse OnSetUserMetadataResponse,
FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
);
* required
ParameterDescription
User
Type: FString
The metadata ID for which to retrieve the user object. Can't be empty.
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.

FPubnubGetMetadataInclude

FieldTypeDescription
IncludeCustom
bool
Whether to include the object's Custom field.
IncludeStatus
bool
Whether to include the object's Status field.
IncludeType
bool
Whether to include the object's Type field.

FOnSetUserMetadataResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
UserData
FPubnubUserData
The user metadata object that was created.

FOnSetUserMetadataResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
UserData
const FPubnubUserData&
The user metadata object that was created.

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



Actor.cpp



Returns

{
"Uuid": "uuid-1",
"Name": "John Doe",
"Email": "john.doe@pubnub.com",
"ExternalId": "",
"ProfileUrl": "",
"Custom": "",
"Updated": "2020-06-17T16:28:14.060718Z"
}

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 metadata for a user with result
Actor.h

Actor.cpp

Set metadata for a user with lambda
Actor.h

Actor.cpp

Set metadata for a user raw
Actor.h

Actor.cpp

Iteratively update existing metadata
Actor.h

Actor.cpp

Remove user metadata

Removes the metadata from a specified User ID.

Method(s)

PubnubSubsystem->RemoveUserMetadata(
FString User,
FOnRemoveUserMetadataResponse OnRemoveUserMetadataResponse
);
* required
ParameterDescription
User
Type: FString
The metadata ID to delete from the user object. Can't be empty.
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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnRemoveUserMetadataResponse struct.

FOnRemoveUserMetadataResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
FOnRemoveUserMetadataResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Remove metadata for a user with result
Actor.h

Actor.cpp

Remove metadata for a user with lambda
Actor.h

Actor.cpp

Channel

Get metadata for all channels

Returns a paginated list of Channel Metadata objects, optionally including the custom data object for each.

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.

PubnubSubsystem->GetAllChannelMetadata(
FOnGetAllChannelMetadataResponse OnGetAllChannelMetadataResponse,
FPubnubGetAllInclude Include = FPubnubGetAllInclude(),
int Limit = 100,
FString Filter = "",
FPubnubGetAllSort Sort = FPubnubGetAllSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
OnGetAllChannelMetadataResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetAllChannelMetadataResponseNative to handle the result using a lambda.
IncludeA list of property names to include in the response.
Limit
Type: int
The maximum number of results to return (default: 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. For example: {name: 'asc'}
PageNext
Type: FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
Type: FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnGetAllChannelMetadataResponse struct.

FOnGetAllChannelMetadataResponse
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
ChannelsData
const TArray<FPubnubChannelData>&
Aa array of FPubnubChannelData structs which are the users with their associated Channel metadata.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FPubnubChannelData
FieldTypeDescription
ChannelID
FString
ID of the channel.
ChannelName
FString
Name of the channel.
Description
FString
Additional description of the channel.
Custom
FString
JSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported.
Status
FString
Channel status. Max 50 characters.
Type
FString
Channel type. Max 50 characters.
Updated
FString
The date when the channel's metadata was last updated.
ETag
FString
Version identifier of the user's metadata.
FOnGetAllChannelMetadataResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
ChannelsData
const TArray<FPubnubChannelData>&
Aa array of FPubnubChannelData structs which are the users with their associated Channel metadata.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Get metadata for all channels with settings
Actor.h

Actor.cpp

Get metadata for all channels with all includes
Actor.h

Actor.cpp

Get metadata for all channels with lambda
Actor.h

Actor.cpp

Get metadata for all channels raw
Actor.h

Actor.cpp

Get channel metadata

Returns metadata for the specified Channel, optionally including the custom data object for each.

Method(s)

PubnubSubsystem->GetChannelMetadata(
FString Include,
FString Channel,
FOnGetChannelMetadataResponse OnGetChannelMetadataResponse
);
* required
ParameterDescription
Include
Type: FString
A comma delimited string with additional/complex user attributes to include in response. Use "" if you don't want to retrieve additional attributes.
Channel
Type: FString
The channel ID for which to retrieve the channel object. Can't be empty.
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.

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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnGetChannelMetadataResponse struct.

FOnGetChannelMetadataResponse
FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
ChannelData
FPubnubChannelData
Aa instance of FPubnubChannelData struct which is the channel with its associated metadata.
FOnGetChannelMetadataResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
ChannelData
const FPubnubChannelData&
Aa instance of FPubnubChannelData struct which is the channel with its associated metadata.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Get metadata for a channel with all includes
Actor.h

Actor.cpp

Get metadata for a channel with lambda
Actor.h

Actor.cpp

Get metadata for a channel raw
Actor.h

Actor.cpp

Set channel metadata with additional settings
Actor.h

Actor.cpp

Set channel metadata with result struct
Actor.h

Actor.cpp

Remove channel metadata with result struct
Actor.h

Actor.cpp

Set channel metadata

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)

PubnubSubsystem->SetChannelMetadata(
FString Channel,
FPubnubChannelData ChannelMetadata,
FOnSetChannelMetadataResponse OnSetChannelMetadataResponse,
FPubnubGetMetadataInclude Include = FPubnubGetMetadataInclude()
);
* required
ParameterDescription
Channel
Type: FString
The metadata ID for which to retrieve the channel object. Can't be empty.
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.

FOnSetChannelMetadataResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
ChannelData
FPubnubChannelData
The channel metadata object that was created.

FOnSetChannelMetadataResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
ChannelData
const FPubnubChannelData&
The channel metadata object that was created.

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



Actor.cpp



Returns

{
"Channel": "my-channel",
"Name": "PubNub channel",
"Description": "The channel for announcements",
"Updated": "2020-06-17T16:52:19.562469Z"
}

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 metadata for a channel with result
Actor.h

Actor.cpp

Set metadata for a channel with lambda
Actor.h

Actor.cpp

Set metadata for a channel raw
Actor.h

Actor.cpp

Iteratively update existing metadata
Actor.h

Actor.cpp

Remove channel metadata

Removes the metadata from a specified channel.

Method(s)

PubnubSubsystem->RemoveChannelMetadata(
FString Channel,
FOnRemoveChannelMetadataResponse OnRemoveChannelMetadataResponse
);
* required
ParameterDescription
Channel
Type: FString
The metadata ID to delete from the channel object. Can't be empty.
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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnRemoveChannelMetadataResponse struct.

FOnRemoveChannelMetadataResponse
FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
FOnRemoveChannelMetadataResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
Remove metadata for a channel with result
Actor.h

Actor.cpp

Remove metadata for a channel with lambda
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.

PubnubSubsystem->GetMemberships(
FString User,
FOnGetMembershipsResponse OnGetMembershipsResponse,
FPubnubMembershipInclude Include = FPubnubMembershipInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMembershipSort Sort = FPubnubMembershipSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
User *
Type: FString
The user ID for whom to retrieve memberships.
OnGetMembershipsResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetMembershipsResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
Limit
Type: int
The maximum number of results to return (default: 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.

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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnGetMembershipsResponse struct.

FOnGetMembershipsResponse

FieldTypeDescription
MembershipsData
TArray<FPubnubMembershipData>&
Aa array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FPubnubMembershipData

FieldTypeDescription
Channel
FPubnubChannelData
Contains channel metadata, including unique channel identifier and other relevant information.
Custom
FString
JSON providing custom data about the membership. Values must be scalar only; arrays or objects are not supported.
Status
FString
Status of the membership. Max 50 characters.
Type
FString
Type of the membership. Max 50 characters.
Updated
FString
The date when the channel's membership was last updated.
ETag
FString
Version identifier of the membership metadata.
FOnGetMembershipsResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembershipsData
const TArray<FPubnubMembershipData>&
Aa array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
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)

PubnubSubsystem->SetMemberships(
FString User,
TArray<FPubnubMembershipInputData> Channels,
FOnSetMembershipsResponse OnSetMembershipsResponse,
FPubnubMembershipInclude Include = FPubnubMembershipInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMembershipSort Sort = FPubnubMembershipSort(),
FString PageNext = "",
FString PagePrev = "");
* required
ParameterDescription
User
Type: FString
The user ID to add/update the memberships. Can't be empty.
ChannelsThe array of channel memberships to add/update. Can't be empty.
FOnSetMembershipsResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnSetMembershipsResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
Limit
Type: int
The maximum number of memberships to return.
Filter
Type: FString
The filter to apply to the memberships.
SortThe sort order to apply to the memberships.
PageNext
Type: FString
The next page token to use for pagination.
PagePrev
Type: FString
The previous page token to use for pagination.
API limits

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

FPubnubMembershipInputData

FieldTypeDescription
Channel
FString
The channel ID to add/update the membership. Can't be empty.
Custom
FString
The custom data to add/update the membership.
Status
FString
The status of the membership.
Type
FString
The type of the membership.

FOnSetMembershipsResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
MembershipsData
TArray<FPubnubMembershipData>&
An array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

FOnSetMembershipsResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembershipsData
const TArray<FPubnubMembershipData>&
An array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

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



Actor.cpp



API limits

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

Returns

{
"Memberships": [
{
"ChannelMetadata": {
"Channel": "my-channel",
"Name": "My channel",
"Description": "A channel that is mine",
"Custom": "",
"Updated": "2020-06-17T16:55:44.632042Z"
},
"Custom": {
"starred": false
},
"Updated": "2020-06-17T17:05:25.987964Z"
},
show all 38 lines

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

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)

PubnubSubsystem->RemoveMemberships(
FString User,
TArray<FString> Channels,
FOnRemoveMembershipsResponse OnRemoveMembershipsResponse,
FPubnubMembershipInclude Include = FPubnubMembershipInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMembershipSort Sort = FPubnubMembershipSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
User
Type: FString
The user ID to remove the memberships. Can't be empty.
Channels
Type: TArray<FString>
The array of channel IDs to remove the memberships. Can't be empty.
FOnRemoveMembershipsResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnRemoveMembershipsResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
Limit
Type: int
The maximum number of memberships to return.
Filter
Type: FString
The filter to apply to the memberships.
SortThe sort order to apply to the memberships.
PageNext
Type: FString
The next page token to use for pagination.
PagePrev
Type: FString
The previous page token to use for pagination.
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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnRemoveMembershipsResponse struct.

FOnRemoveMembershipsResponse
FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
MembershipsData
TArray<FPubnubMembershipData>&
An array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FOnRemoveMembershipsResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembershipsData
const TArray<FPubnubMembershipData>&
An array of FPubnubMembershipData structs which are the memberships of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
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.

PubnubSubsystem->GetChannelMembers(
FString Channel,
FOnGetChannelMembersResponse OnGetChannelMembersResponse,
FPubnubMemberInclude Include = FPubnubMemberInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMemberSort Sort = FPubnubMemberSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
Channel *
Type: FString
The Channel ID for which to retrieve members.
OnGetChannelMembersResponse *The delegate for the operation's result.

You can also use a native callback of the type FOnGetChannelMembersResponseNative to handle the result using a lambda.
IncludeA comma-separated list of property names to include in the response.
Limit
Type: int
The maximum number of results to return (default: 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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnGetChannelMembersResponse struct.

FOnGetChannelMembersResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
MembersData
TArray<FPubnubChannelMemberData>&
Aa array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FPubnubChannelMemberData
FieldTypeDescription
User
FPubnubUserData
Contains user metadata, including unique channel identifier and other relevant information.
Custom
FString
JSON providing custom data about the member. Values must be scalar only; arrays or objects are not supported.
Status
FString
Status of the member. Max 50 characters.
Type
FString
Type of the member. Max 50 characters.
Updated
FString
The date when the channel's member was last updated.
ETag
FString
Version identifier of the member metadata.
FOnGetChannelMembersResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembersData
const TArray<FPubnubChannelMemberData>&
Aa array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
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)

PubnubSubsystem->SetChannelMembers(
FString Channel,
TArray<FPubnubChannelMemberInputData> Users,
FOnSetChannelMembersResponse OnSetChannelMembersResponse,
FPubnubMemberInclude Include = FPubnubMemberInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMemberSort Sort = FPubnubMemberSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
Channel
Type: FString
The channel ID to add/update the members. Can't be empty.
UsersThe array of channel members to add/update. Can't be empty.
FOnSetChannelMembersResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnSetChannelMembersResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
Limit
Type: int
The maximum number of members to return.
Filter
Type: FString
The filter to apply to the members.
SortThe sort order to apply to the members.
PageNext
Type: FString
The next page token to use for pagination.
PagePrev
Type: FString
The previous page token to use for pagination.
API limits

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

FPubnubChannelMemberInputData

FieldTypeDescription
User
FString
The user ID to add/update the membership. Can't be empty.
Custom
FString
The custom data to add/update the membership.
Status
FString
The status of the membership.
Type
FString
The type of the membership.

FOnSetChannelMembersResponse

FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
MembersData
TArray<FPubnubChannelMemberData>&
An array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

FOnSetChannelMembersResponseNative

FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembersData
const TArray<FPubnubChannelMemberData>&
An array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

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



Actor.cpp



API limits

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

Returns

{
"ChannelMembers": [
{
"UuidMetadata": {
"Uuid": "uuid-1",
"Name": "John Doe",
"Email": "john.doe@pubnub.com",
"ExternalId": "",
"ProfileUrl": "",
"Custom": "",
"Updated": "2019-02-20T23:11:20.89375"
},
"Custom": {
"role": "admin"
},
show all 39 lines

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

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)

PubnubSubsystem->RemoveChannelMembers(
FString Channel,
TArray<FString> Users,
FOnRemoveChannelMembersResponse OnRemoveChannelMembersResponse,
FPubnubMemberInclude Include = FPubnubMemberInclude(),
int Limit = 100,
FString Filter = "",
FPubnubMemberSort Sort = FPubnubMemberSort(),
FString PageNext = "",
FString PagePrev = ""
);
* required
ParameterDescription
Channel
Type: FString
The channel ID to remove the members. Can't be empty.
Users
Type: TArray<FString>
The array of user IDs to remove from the channel. Can't be empty.
FOnRemoveChannelMembersResponseThe delegate for the operation's result.

You can also use a native callback of the type FOnRemoveChannelMembersResponseNative to handle the result using a lambda.
IncludeList of property names to include in the response.
Limit
Type: int
The maximum number of members to return.
Filter
Type: FString
The filter to apply to the members.
SortThe sort order to apply to the members.
PageNext
Type: FString
The next page token to use for pagination.
PagePrev
Type: FString
The previous page token to use for pagination.

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



Actor.cpp



Returns

This function is void, but the delegate returns the FOnRemoveChannelMembersResponse struct.

FOnRemoveChannelMembersResponse
FieldTypeDescription
Result
FPubnubOperationResult
The result of the operation.
MembersData
TArray<FPubnubChannelMemberData>&
An array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.
FOnRemoveChannelMembersResponseNative
FieldTypeDescription
Result
const FPubnubOperationResult&
The result of the operation.
MembersData
const TArray<FPubnubChannelMemberData>&
An array of FPubnubChannelMemberData structs which are the members of the channel.
PageNext
FString
Random string returned from the server, indicating a specific position in a data set. Used for forward pagination, it fetches the next page, allowing you to continue from where you left off.
PagePrev
FString
Random string returned from the server, indicating a specific position in a data set. Used for backward pagination, it fetches the previous page, enabling access to earlier data. Ignored if the pageNext parameter is supplied.

Other examples

Reference code
Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code.
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

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

ASample_AppContextFull.h


ASample_AppContextFull.cpp


Last updated on