Invite users to channels

Let users invite one or more people to a private or group conversation and sets their channel membership.

icon

Usage in Blueprints and C++


Requires App Context

To manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.

As a result or inviting one or more users to a direct or group channel, an event of the invite type gets created. You can listen to these events in your chat app and notify the invited users.

Not available for public chats

Invitations are disabled in public chats. If you try implementing this feature in a public channel type, you'll get the Channel invites are not supported in Public chats error.

Unreal Chat SDK doesn't provide any default logic that is triggered when one user invites another user to join a channel. However, if you want the invited user to receive a notification about the new invitation, you can implement custom logic in your chat app that will:

Invite one user

Invite() requests another user to join a channel and become its member.

Method signature

Input

ParameterTypeRequiredDefaultDescription
UserUPubnubUser*Yesn/aUser that you want to invite to a 1:1 channel.

Output

TypeDescription
UPubnubMembership*Returned (modified) object containing the membership data.

Basic usage

Invite support-agent-15 to join the high-prio-incidents channel.

#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");

UPubnubChannel* Channel = Chat->GetChannel("high-prio-incidents");

// Define user ID
FString UserID = "support_agent_15";

// Get the user and save the reference
UPubnubUser* User = Chat->GetUser(UserID);
show all 17 lines

Invite multiple users

InviteMultiple() requests other users to join a channel and become its members. You can invite up to 100 users at once.

Method signature

Input

ParameterTypeRequiredDefaultDescription
UsersTArray<UPubnubUser*>Yesn/aArray of users you want to invite to the group channel. You can invite up to 100 users in one call.

Output

TypeDescription
TArray<UPubnubMembership*>Returned (modified) array of objects containing the membership data.

Basic usage

Invite support-agent-15 and support-agent-16 to join the high-prio-incidents channel.

#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");

UPubnubChannel* Channel = Chat->GetChannel("high-prio-incidents");

// Define user IDs
FString UserID1 = "support_agent_15";
FString UserID2 = "support_agent_16";

// Get the user and save the reference
show all 23 lines

Listen to invite events

As an admin of your chat app, you can use the ListenForEvents() method to monitor all events emitted when someone invites a person to a direct or group channel. You can use this method to send notifications to the invited users.

Events documentation

To read more about the events of type invite, refer to the Chat events documentation.

Method signature

icon

Handle the response

Output

This method doesn't return any value.

Basic usage

Listen for invitations received on the support channel.

#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");

FString ChannelID = "support";

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

show all 20 lines
Last updated on