Initial configuration
Initialize and configure the Unreal Chat SDK before building your chat app.
Prerequisites
- Sign in or create an account on the Admin Portal.
- 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
- Download and install Unreal Engine version 5.0 or higher.
- Create a new blank C++ Unreal project in a location of your choice.
- Create an empty
Pluginsfolder 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:
- Clone the content of the Unreal Engine Chat SDK repository: Unreal Engine Chat.
- Rename the cloned folder to
PubnubChatSDK.
Configure the workspace
-
In the project's root folder, right-click the
projectname.uprojectfile and select the appropriate option for your operating system:OS Selection MacOS Services -> Generate xCode project Windows Generate Visual Studio project files -
Open the generated workspace for your OS.
-
Navigate to
Source/_{YourProject}_/_{YourProject}_.Build.csand add a dependency toPubnubChatSDK.PrivateDependencyModuleNames.AddRange(new string[] { "PubnubChatSDK" }); -
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.
- Blueprint
- C++ / Input parameters
1UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
2
3UPubnubChat* Chat = PubnubChatSubsystem->InitChat("Publish Key", "Subscribe Key", "User Id");
Input parameters
| Parameter | Feature | Description |
|---|---|---|
Publish Key *Type: StringDefault: n/a | Send messages | Specifies the key used to publish messages on a channel. |
Subscribe Key *Type: StringDefault: n/a | Receive messages | Specifies the key used to subscribe to a channel. |
User Id *Type: StringDefault: 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 KeyType: StringDefault: n/a | Moderation | Specifies the key used to authorize operations in PubNub's Access Manager system. |
Config → Typing TimeoutType: IntegerDefault: 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 DifferenceType: IntegerDefault: 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 → StoreUserActivityTypestampType: BoolDefault: 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 → StoreUserActivityIntervalType: IntegerDefault: 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
| Type | Description |
|---|---|
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.
- Create an empty C++ class (Tools -> Add C++ Class) with
Noneas the parent. - Remove the
Intermediate,Build, andBinariesfolders. - Rebuild and reopen the project.
For more information, refer to Unreal Engine Forums.
Next steps
After initialization, you can:
- Create channels and users
- Add features like messaging, typing indicators, and presence