On this page

Initial configuration

Initialize and configure the Unreal Chat SDK before building your chat app.

icon

Usage in Blueprints and C++


Prerequisites

  1. Sign in or create an account on the Admin Portal.
  2. Create an app to get your Publish Key and Subscribe Key.
Limit of 3 keysets for Free tier accounts

Effective February 3, 2025, all Free tier accounts are limited to a maximum of three keysets. If your account exceeds this limit, you must delete existing keysets to create new ones.

A new app receives demo keys automatically. You can create multiple keysets per app. Use separate keysets for production and test environments.

Required keyset settings

Enable these features on your keyset in the Admin Portal:

  • App Context - Store user and channel data
  • Presence - Track online/offline status
  • Message Persistence - Store message history

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.
Blueprint project package bug

If you create a Blueprint project, you may encounter a bug when packaging your app. Refer to Package a Blueprint project for more information.

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. Rename the cloned folder to PubnubChatSDK.

Configure the workspace

  1. In the project's root folder, right-click the projectname.uproject file and select the appropriate option for your operating system:

    OSSelection
    MacOS
    Services -> Generate xCode project
    Windows
    Generate Visual Studio project files
  2. Open the generated workspace for your OS.

  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

Use the Init Chat method to create a Chat SDK instance. Three parameters are required: Publish Key, Subscribe Key, and User Id.

Optional parameters configure features like typing indicators and presence tracking.

Input parameters

* required
ParameterFeatureDescription
Publish Key *
Type: String
Default:
n/a
Send messages
Specifies the key used to publish messages on a channel.
Subscribe Key *
Type: String
Default:
n/a
Receive messages
Specifies the key used to subscribe to a channel.
User Id *
Type: String
Default:
n/a
n/a
Unique 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 Key
Type: String
Default:
n/a
Moderation
Specifies the key used to authorize operations in PubNub's Access Manager system.
Config → Typing Timeout
Type: Integer
Default:
5000
Typing Indicator
Specifies 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 Difference
Type: Integer
Default:
1000
Typing Indicator
Specifies 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 → StoreUserActivityTypestamp
Type: Bool
Default:
False
User's last online activity, global presence
Specifies 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 → StoreUserActivityInterval
Type: Integer
Default:
600000
User's last online activity, global presence
Specifies 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 Chat
Object returning a new PubNub chat instance.

Package a Blueprint project

A bug in Unreal Engine can cause C++ plugins to fail when packaging Blueprint projects. Create a C++ source file in your project to resolve the Plugin X failed to load error.

  1. Create an empty C++ class (Tools -> Add C++ Class) with None as the parent.
  2. Remove the Intermediate, Build, and Binaries folders.
  3. Rebuild and reopen the project.

For more information, refer to Unreal Engine Forums.

Next steps

After initialization, you can:

Last updated on