The Braze Unreal SDK integrates the Braze SDK for Android and iOS with UE4. Android and iOS are the only supported platforms.
The Braze Unreal SDK has two parts:
- Braze Plugin - Located in BrazeSample/Plugins/Braze. This is the module that provides Braze functionality, which you will integrate into your own app.
- Braze Sample - This is a sample project demonstrating the integration of the Braze Plugin. Use this as a helpful reference for using the plugin.
- Copy BrazeSample/Plugins/Braze into your own app's Plugin folder.
- Enable the Plugin
- If using a C++ Project, configure your module to reference the Braze module. In your *.Build.cs file, add "Braze" to your PublicDependencyModuleNames. Ex:
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "Braze" });
- Configure your DefaultEngine.ini with your API keys and your Endpoint.
[/Script/Braze.BrazeConfig]
bAutoInitialize=True ; true by default, initialize when the project starts
AndroidApiKey= ; your API key
IOSApiKey= ; your API key
CustomEndpoint= ; your endpoint
Warning For projects targeting Android SDK 31+ Unreal will generate builds that will fail during installation on Android 12+ devices with the INSTALL_PARSE_FAILED_MANIFEST_MALFORMED error. To fix this, locate the
UE4_Engine_AndroidSDK_31_Build_Fix.patch
git patch file in the root of this repository and apply it to your Unreal source build.
If you'd like precise control over when Braze initializes, you may disable AutoInitialize in the DefaultEngine.ini. With AutoInitialize disabled, you'll need to manually initialize Braze from native C++ or Blueprint.
In native C++, access the BrazeSubsystem and call InitializeBraze()
optionally passing it a Config to override Engine.ini settings.
UBrazeSubsystem* const BrazeSubsystem = GEngine->GetEngineSubsystem<UBrazeSubsystem>();
UBraze* const BrazeInstance = BrazeSubsystem->InitializeBraze();
In Blueprint, the same functions are accessible as Blueprint nodes:
Use the GetBrazeSubsystem
Node to call its Initialize
node.
A BrazeConfig object can optionally be created in Blueprint and passed to Initialize
Enabling Braze SDK Level logging on iOS via the info.plist is also possible in UE4. Navigate Settings -> Project Settings, then navigate to IOS on the left pane (under the Platforms heading). In the Right pane, search for the Extra PList Data
heading and in the Additional Plist Data
field you can enter the following to specify logging verbosity from the SDK:
<key>Appboy</key>
<dict>
<key>LogLevel</key>
<string>0</string>
</dict>
The default log level is 8, which is minimal logging. Read more about log levels: Other SDK Customization
On Android, Enabling Braze SDK Level Logging is done at runtime by calling UBrazeSubsystem::AndroidSetLogLevel
.
UBrazeSubsystem* const BrazeSubsystem = GEngine->GetEngineSubsystem<UBrazeSubsystem>();
BrazeSubsystem->AndroidSetLogLevel(EBrazeLogLevel::Verbose);
UBraze* const BrazeInstance = BrazeSubsystem->InitializeBraze();
In Blueprint, the same function is accessible as a node:
In order to ensure logging is set when the Braze SDK Initialize is called, it is recommended to call this before InitializeBraze
.
The Braze Unreal SDK supports the following analytics functions. Read more about using Braze in the Braze Documentation.
UBraze functions:
- ChangeUser
- LogCustomEvent
- LogCustomEventWithProperties
- LogPurchase
- LogPurchaseWithProperties
- RequestImmediateDataFlush
- GetCurrentUser
UBrazeUser functions:
- SetCustomUserAttribute* - Supports String, Int, Long, Float, Bool, Date
- SetCustomAttributeArray
- UnsetCustomAttribute
- IncrementCustomUserAttribute
- AddToCustomAttributeArray
- RemoveFromCustomAttributeArray
- SetEmail
- SetFirstName
- SetLastName
- SetGender
- SetLanguage
- SetCountry
- SetHomeCity
- SetPhoneNumber
- SetDateOfBirth
- SetPushSubscriptionType
- SetEmailSubscriptionType
- SetAttributionData
- SetLastKnownLocation
The Blueprint Library BrazePropertiesLibrary includes helper functions to make creating BrazeProperties easier. Use the Make FBrazeAny*
Nodes with a MakeMap
when using the MakeBrazeProperties
node. For example:
In order to enable Push Notifications to Android via Firebase Coud Messaging (FCM), do the following:
- Add the following lines to your engine.ini for your project:
- bEnableFirebaseCloudMessagingSupport=true
- bIsFirebaseCloudMessagingRegistrationEnabled=true
- Setup your application with FCM
- Add FirebaseCloudMessagingSenderIdKey= to your engine.ini for your project.
- Also See Step 4 of the Braze Integration document to setup your credentials on the dashboard.
- Create
AndroidCopies
folder next to the BrazeUPLAndroid.xml. Add yourgoogle-services.json
to the top of this folder.
To set the small and large notification icons:
- Add icons to the appropriate drawable folder (
drawable
by default) inside of theAndroidCopies/res
folder. - Add
braze.xml
to theAndroidCopies/res/values
folder to set the icons. A very basic braze.xml file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<drawable name="com_braze_push_small_notification_icon">@drawable/notification_small_icon</drawable>
<drawable name="com_braze_push_large_notification_icon">@drawable/notification_large_icon</drawable>
</resources>
Note The files from the
AndroidCopies
folder will be copied into the generated Android project structure as defined in theBrazeUPLAndroid.xml
.
In order to enable Push Notifications to iOS, do the following:
- Follow the first step from the Braze Integration document to create your P8.
- "Enable Remote Notifications Support" under Settings -> Project Settings -> iOS -> Online to setup your project for Push Capabilities
- In order to do this, the project must be built using Engine Source.
- Make sure your provision has Push capabilities enabled.
As of 4.25.3, UE4 lacks proper support to receive a remote notification that causes the initial launch of the application. In order to support receiving this notification, we've created two git patches to apply - one for UE4 and one for the Braze SDK plugin.
- To your UE4 Engine Source folder, apply the git patch
UE4_Engine-Cache-Launch-Remote-Notification.patch
- To the Braze Unreal SDK folder, apply the git patch
Braze_SDK-Read-Cached-Remote-Launch-Notification.patch