Manage user details
Get details about the app users.
Get user details
Return data about a specific user with the GetUser()
method.
By default, this method returns all custom user metadata without the need to define that during the call explicitly.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
- Blueprint
- C++ / Input parameters
Chat->GetUser(FString UserID)
Parameter | Type | Required | Description |
---|---|---|---|
UserID | FString | Yes | Unique user identifier. |
Output
Type | Description |
---|---|
UPubnubUser* | Returned object containing the user metadata or a null value if the user doesn't exist. |
Basic usage
Get details on user support_agent_15
.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
// Define user ID
FString UserID = "support_agent_15";
// Get the user and save the reference
UPubnubUser* User = Chat->GetUser(UserID);
Get current user
CurrentUser
is a getter method that returns the current chat user of the chat app.
Requires App Context
To store data about users, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
- Blueprint
- C++ / Input parameters
Chat->CurrentUser();
Output
Type | Description |
---|---|
UPubnubUser* | Returned User object. |
Basic usage
Return the current chat user.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
// Define user ID
FString UserID = "support_agent_15";
// Get the user and save the reference
UPubnubUser* User = Chat->CurrentUser();
Get user ID
GetUserID
is a getter method that returns the current chat user's ID.
Method signature
- Blueprint
- C++ / Input parameters
User->GetUserID();
Output
Type | Description |
---|---|
FString* | Returned user ID. |
Basic usage
Return the current chat user's ID.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
// Define user ID
FString UserID = "support_agent_15";
// Get the user and save the reference
UPubnubUser* User = Chat->CurrentUser();
FString ReturnedUserID = User->GetUserID();
Get user data
GetUserData
is a getter method that returns the current chat user's data.
Method signature
- Blueprint
- C++ / Input parameters
User->GetUserData();
Output
Type | Description |
---|---|
FPubnubChatUserData* | Returned user data. |
Basic usage
Return the current chat user's data.
#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"
UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
// Define user ID
FString UserID = "support_agent_15";
// Get the user and save the reference
UPubnubUser* User = Chat->CurrentUser();
FPubnubChatUserData UserData = User->GetUserData();