Initial configuration

Before building your chat app, you must initialize and configure the Unreal Chat SDK.

icon

Usage in Blueprints and C++


Start by signing into the Admin Portal or creating an account if you don't have one yet.

Then, create an app on the Admin Portal. You will need a PubNub app to get a keyset that consists of a Subscribe Key and a Publish Key. These keys will let you establish a connection between PubNub and the chat app you're going to create with the Unreal Engine Chat SDK.

When you create a new app on the Admin Portal, the first set of demo keys is generated automatically, but a single app can have as many keysets as you like. We recommend that you create separate keysets for production and test environments.

Keyset configuration

Each keyset has its own configuration settings in the Admin Portal. To develop some features in your chat app, you must enable appropriate settings on your app's keyset on the Admin Portal.

For example, to create or update users in your chat, you'll need to enable App Context on the keyset for PubNub to manage that user metadata. Similarly, you'll need to enable Presence to track a user's channel presence or enable Message Persistence to store messages in PubNub history. You can enable these features at any time - the docs will instruct you and show which setting needs enabling on your keyset for a given chat feature to work.

Configure Unreal Engine

  1. Download and install Unreal Engine version 5.0 or higher.

  2. Create a new blank C++ Unreal project in a location of your choice.

  3. Create an empty Plugins folder in your Unreal project's location.

Download the SDK

In the Plugins folder of your Unreal project:

  1. Clone the content of the Unreal Engine Chat SDK repository: Unreal Engine Chat.

  2. Change the folder name in which you cloned the content to PubnubChatSDK.

Configure the workspace

  1. In the project's root folder, right-click the projectname.uproject file and, depending on your operating system (OS), select:

    OSSelection
    MacOSServices -> Generate xCode project
    WindowsGenerate Visual Studio project files
  2. Wait until the files are generated and open your OS-specific workspace.

  3. Navigate to Source/_{YourProject}_/_{YourProject}_.Build.cs and add a dependency to PubnubChatSDK.

    PrivateDependencyModuleNames.AddRange(new string[] { "PubnubChatSDK" });
  4. Compile the code and run the project.

Initialize PubNub

Once you have a PubNub account and an app created on the Admin Portal, you can start initializing PubNub Client API context and establish account-level credentials.

To initialize PubNub with the Unreal Chat SDK, use the Init Chat method.

You must provide at least these three parameters: Publish Key, Subscribe Key, or User ID. Apart from the required parameters, you can also configure additional options when initializing the Unreal Chat SDK. These options will let you add configuration required to implement advanced chat features, like typing indicator, user offline/online presence, push notifications, or client-side limiting that prevents spamming.

Input parameters

ParameterTypeRequiredDefaultFeatureDescription
Publish KeyStringYesn/aSend messagesSpecifies the key used to publish messages on a channel.
Subscribe KeyStringYesn/aReceive messagesSpecifies the key used to subscribe to a channel.
User IdStringYesn/an/aUnique User ID that becomes your app's current user. It's a string of up to 92 characters that identifies a single client (end user, device, or server) that connects to PubNub. Based on User ID, PubNub calculates pricing for your apps' usage. User ID should be persisted and remain unchanged. If you don't set userId, you won't be able to connect to PubNub.
Config → Auth KeyStringYesn/aModerationSpecifies the key used to authorize operations in PubNub's Access Manager system.
Config → Typing TimeoutIntegerNo5000Typing IndicatorSpecifies the default timeout after which the typing indicator automatically stops when no typing signals are received. The default and maximum value is set to 5000 milliseconds (5 seconds).
Config → Typing Timeout DifferenceIntegerNo1000Typing IndicatorSpecifies the difference in time between actually sending the typing indicator and the value of Typing Timeout. This is designed to cover for any network lag that may occur. If you set the Typing Timeout to 5 seconds and the Typing Timeout Difference to 1 second, the typing signal stops between the fourth and fifth second. The default value is set to 1000 milliseconds (1 second).

Output parameters

TypeDescription
PubNub ChatObject returning a new PubNub chat instance.

Next steps

Now that you've initialized and configured the Unreal Chat SDK, you can start creating channels, adding users, and powering your app with all sorts of features.

Last updated on