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.

Enable features on your keyset

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

To use the Chat SDK, create or update users, track presence, and store messages in history, you must enable App Context, Presence, and Message Persistence.

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.

    Blueprint project package bug

    If you decide to create a Blueprint project, you may run into a bug when you package your app. Refer to Package a Blueprint project for more information.

  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 KeyStringNon/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).
Config → StoreUserActivityTypestampBoolNoFalseUser's last online activity, global presenceSpecifies if you want to track the user's global presence in your chat app. The user's activity is tracked through the LastActiveTimeStamp parameter on the User object.
Config → StoreUserActivityIntervalIntegerNo600000User's last online activity, global presenceSpecifies how often the user global presence in the app should be updated. Requires StoreUserActivityTimestamp to be set to True. The default value is set to 600000 milliseconds (10 minutes), and the minimum possible value is 60000 milliseconds (1 minute). If you try to set it to a lower value, you'll get the StoreUserActivityInterval must be at least 60000ms error.

Output parameters

TypeDescription
PubNub ChatObject returning a new PubNub chat instance.

Package a Blueprint Project

Because of a bug in Unreal Engine, sometimes C++ plugins fail to load when you package your Blueprint project.

To resolve the Plugin X failed to load error, you must create a C++ source file in your project otherwise the plugins are going to be excluded.

To resolve the plugin error when building a Blueprint project:

  1. In your project, create (Tools-> Add C++ Class) an empty C++ class with None as the parent.

  2. Remove the Intermediate, Build, and Binaries folders and rebuild the project.

  3. Reopen the project.

For more information, refer to Unreal Engine Forums.

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