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
1Chat->GetUser(FString UserID)
| Parameter | Description |
|---|---|
UserID *Type: FString | Unique user identifier. |
Output
| Type | Description |
|---|---|
UPubnubUser* | Returned object containing the user metadata or a null value if the user doesn't exist. |
Sample code
Get details on user support_agent_15.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* 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
1Chat->CurrentUser();
Output
| Type | Description |
|---|---|
UPubnubUser* | Returned User object. |
Sample code
Return the current chat user.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* 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
1User->GetUserID();
Output
| Type | Description |
|---|---|
FString* | Returned user ID. |
Sample code
Return the current chat user's ID.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->CurrentUser();
14
15FString 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
1User->GetUserData();
Output
| Type | Description |
|---|---|
FPubnubChatUserData* | Returned user data. |
Sample code
Return the current chat user's data.
1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9// Define user ID
10FString UserID = "support_agent_15";
11
12// Get the user and save the reference
13UPubnubUser* User = Chat->CurrentUser();
14
15FPubnubChatUserData UserData = User->GetUserData();