App Context API for PubNub 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 set or removed from the database. 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 UUID Metadata objects, optionally including the custom data object for each.

Method(s)

Response variants

You can also call the GetAllUUIDMetadata_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelName = "randomChannel";

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetAllUUIDMetadataResponse OnGetAllUUIDMetadataResponse;
OnGetAllUUIDMetadataResponse.BindDynamic(this, &AMyActor::OnGetAllUUIDMetadataResponse);

int Limit = 10; // Limit to 10 objects
EPubnubTribool Count = pbccFalse; // Don't include total count
show all 17 lines

Returns

This method returns the FOnGetAllUUIDMetadataResponse struct.

FOnGetAllUUIDMetadataResponse

FieldTypeDescription
StatusintHTTP code of the result of the operation.
UsersDataTArray<FPubnubUserData>&Aa array of FPubnubUserData structs which are the users with their associated UUID metadata.
PageNextFStringRandom 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.
PagePrevFStringRandom 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
UserIDFStringUnique user identifier. If not supplied, then the current user's UUID is used.
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.
CustomFStringJSON providing custom data about the user. Values must be scalar only; arrays or objects are not supported.
StatusFStringUser type. Max. 50 characters.
TypeFStringUser status. Max. 50 characters.
UpdatedFStringThe date when the user's metadata was last updated.
ETagFStringInformation on the object's content fingerprint.
JSON Response
{
"Uuids": [
{
"Uuid": "uuid-1",
"Name": "John Doe",
"Email": "john.doe@pubnub.com",
"ExternalId": "",
"ProfileUrl": "",
"Custom": "",
"Updated": "2020-06-17T16:28:14.060718Z"
},
{
"Uuid": "uuid-2",
"Name": "Bob Cat",
"Email": "bobc@example.com",
show all 29 lines

Get User Metadata

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

Method(s)

Response variants

You can also call the GetUUIDMetadata_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetUUIDMetadataResponse OnGetUUIDMetadataResponse;
OnGetUUIDMetadataResponse.BindDynamic(this, &AMyActor::OnGetUUIDMetadataResponse);

FString Include = ""; // No additional attributes
FString UUIDMetadataId = "uuid-1";

PubnubSubsystem->GetUUIDMetadata(Include, Limit, Start, End, Count, OnGetUUIDMetadataResponse);

Returns

This method returns the FOnGetUUIDMetadataResponse struct.

FOnGetUUIDMetadataResponse

FieldTypeDescription
StatusintHTTP code of the result of the operation.
UserDataFPubnubUserDataAa instance of FPubnubUserData struct which is the user with their associated UUID metadata.

JSON Response

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

Set User Metadata

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

Method(s)

API limits

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

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString UUIDMetadataID = TEXT("user123"); // Example UUID Metadata ID
FString Include = ""; // No additional attributes
FString UUIDMetadataObj = TEXT("{\"name\":\"John Doe\",\"email\":\"johndoe@example.com\"}"); // Example JSON object

// Call the SetUUIDMetadata method
PubnubSubsystem->SetUUIDMetadata(UUIDMetadataID, Include, UUIDMetadataObj);

Returns

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

Remove User Metadata

Removes the metadata from a specified UUID.

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString UUIDMetadataID = TEXT("user123"); // Example UUID Metadata ID

// Call the RemoveUUIDMetadata method
PubnubSubsystem->RemoveUUIDMetadata(UUIDMetadataID);

Returns

This method doesn't have any return value.

Channel

Get Metadata for All Channels

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

Method(s)

Response variants

You can also call the GetAllChannelMetadata_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelName = "randomChannel";

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetAllChannelMetadataResponse OnGetAllUUIDMetadataResponse;
OnGetAllUUIDMetadataResponse.BindDynamic(this, &AMyActor::OnGetAllUUIDMetadataResponse);

int Limit = 10; // Limit to 10 objects
EPubnubTribool Count = pbccFalse; // Don't include total count
show all 17 lines

Returns

This method returns the FOnGetAllChannelMetadataResponse struct.

FOnGetAllChannelMetadataResponse

FieldTypeDescription
StatusintHTTP code of the result of the operation.
ChannelsDataTArray<FPubnubChannelData>&Aa array of FPubnubChannelData structs which are the users with their associated UUID metadata.
PageNextFStringRandom 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.
PagePrevFStringRandom 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
UserFPubnubUserDataContains user metadata, including unique user identifier, display name, external ID, profile URL, and email address.
CustomFStringJSON providing custom data about the user. Values must be scalar only; arrays or objects are not 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 user's metadata.
JSON Response
{
"Channels": [
{
"Channel": "my-channel",
"Name": "My channel",
"Description": "A channel that is mine",
"Custom": "",
"Updated": "2020-06-17T16:52:19.562469Z"
},
{
"Channel": "main",
"Name": "Main channel",
"Description": "The main channel",
"Custom": {
"public": true,
show all 26 lines

Get Channel Metadata

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

Method(s)

Response variants

You can also call the GetChannelMetadata_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetChannelMetadataResponse OnGetChannelMetadataResponse;
OnGetChannelMetadataResponse.BindDynamic(this, &AMyActor::OnGetChannelMetadataResponse);

FString Include = ""; // No additional attributes
FString ChannelMetadataID = "my-channel";

PubnubSubsystem->GetChannelMetadata(Include, ChannelMetadataID, OnGetChannelMetadataResponse);

Returns

This method returns the FOnGetChannelMetadataResponse struct.

FOnGetChannelMetadataResponse

FieldTypeDescription
StatusintHTTP code of the result of the operation.
ChannelDataFPubnubChannelDataAa instance of FPubnubChannelData struct which is the channel with its associated metadata.
JSON Response
{
"Channel": "my-channel",
"Name": "My channel",
"Description": "A channel that is mine",
"Custom": "",
"Updated": "2020-06-17T16:52:19.562469Z"
}

Set Channel Metadata

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

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelMetadataID = TEXT("myChannel"); // Example Channel Metadata ID
FString Include = ""; // No additional attributes
FString ChannelMetadataObj = TEXT("{\"name\":\"PubNub channel\",\"description\":\"The channel for announcements\"}"); // Example JSON object

// Call the SetChannelMetadata method
PubnubSubsystem->SetChannelMetadata(ChannelMetadataID, Include, ChannelMetadataObj);
API limits

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

Returns

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

Remove Channel Metadata

Removes the metadata from a specified channel.

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelMetadataID = TEXT("myChannel"); // Example Channel Metadata ID

// Call the RemoveChannelMetadata method
PubnubSubsystem->RemoveChannelMetadata(ChannelMetadataID);

Returns

This method doesn't have any return value.

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)

Response variants

You can also call the GetMemberships_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelName = "randomChannel";

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetMembershipsResponse OnGetMembershipResponse;
OnGetMembershipResponse.BindDynamic(this, &AMyActor::OnGetMembershipResponse);

UUIDMetadataID UserId = "user-1"
int Limit = 10; // Limit to 10 objects
show all 18 lines

Returns

This method returns the FOnGetMembershipsResponse struct.

FOnGetMembershipsResponse
FieldTypeDescription
StatusintHTTP code of the result of the operation.
MembershipsDataTArray<FPubnubGetChannelMembershipWrapper>&Aa array of FPubnubGetChannelMembershipsWrapper structs which are the memberships of the channel.
PageNextFStringRandom 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.
PagePrevFStringRandom 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.
FPubnubGetChannelMembershipsWrapper

FieldTypeDescription
ChannelFPubnubChannelDataContains channel metadata, including unique channel identifier and other relevant information.
CustomFStringJSON providing custom data about the membership. Values must be scalar only; arrays or objects are not 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.
JSON Response
{
"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

Set Channel Memberships

Set channel memberships for a UUID.

Method(s)

API limits

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

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString UUIDMetadataID = TEXT("user123"); // Example User ID
FString Include = ""; // No additional attributes
FString SetObj = TEXT("{\"channels\": [{\"channel123\": {\"name\":\"Channel One\"}}]}"); // Example JSON object

// Call the SetMemberships method
PubnubSubsystem->SetMemberships(UUIDMetadataID, Include, SetObj);
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

Remove Channel Memberships

Remove channel memberships for a user.

Method(s)

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString UUIDMetadataID = TEXT("user123"); // Example User ID
FString Include = ""; // No additional attributes
FString RemoveObj = TEXT("{\"channels\": [{\"channel123\": {\"name\":\"Channel One\"}}]}"); // Example JSON object

// Call the RemoveMemberships method
PubnubSubsystem->RemoveMemberships(UUIDMetadataID, Include, RemoveObj);

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

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)

Response variants

You can also call the GetChannelMembers_JSON() variant of this method to get an FOnPubnubResponse which contains pure JSON.

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnGetChannelMembersResponse OnGetMembersResponse;
OnGetMembersResponse.BindDynamic(this, &AMyActor::OnGetMembersResponse);

FString ChannelMetadataID = "my-channel";
int Limit = 10; // Limit to 10 objects
EPubnubTribool Count = pbccFalse; // Don't include total count

show all 16 lines

Returns

This method returns the FOnGetChannelMembersResponse struct.

FOnGetChannelMembersResponse

FieldTypeDescription
StatusintHTTP code of the result of the operation.
MembersDataTArray<FPubnubGetChannelMembersWrapper>&Aa array of FPubnubGetChannelMembersWrapper structs which are the members of the channel.
PageNextFStringRandom 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.
PagePrevFStringRandom 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.
FPubnubGetChannelMembersWrapper

FieldTypeDescription
UserFPubnubUserlDataContains user metadata, including unique channel identifier and other relevant information.
CustomFStringJSON providing custom data about the member. Values must be scalar only; arrays or objects are not 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.
JSON Response
{
"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

Set Channel Members

This method sets members in a channel.

Method(s)

API limits

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

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelMetadataID = "myChannel";
FString Include = ""; // No additional attributes
FString SetObj = TEXT([{"id": "some-user-id", "custom": {"starred": true}}, {"id": "user-0-id", "some_key": {"other_key": "other_value"}}]); // Example JSON object

// Call the SetChannelMembers method
PubnubSubsystem->SetChannelMembers(ChannelMetadataID, Include, SetObj);
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

Remove Channel Members

Remove members from a channel.

Method(s)

API limits

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

Basic Usage

#include "Kismet/GameplayStatics.h"
#include "PubnubSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubSubsystem* PubnubSubsystem = GameInstance->GetSubsystem<UPubnubSubsystem>();

FString ChannelMetadataID = "myChannel";
FString Include = ""; // No additional attributes
FString RemoveObj = TEXT([{"id": "some-user-id", "custom": {"starred": true}}, {"id": "user-0-id", "some_key": {"other_key": "other_value"}}]); // Example JSON object

// Call the RemoveChannelMembers method
PubnubSubsystem->RemoveChannelMembers(ChannelMetadataID, Include, RemoveObj);

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
Last updated on