Unreal Engine

Plugin installation

The SDK can be found in the devtodev GitHub repository. Download the latest release of the Source code (zip). Unzip the archive and copy the DTDMessaging folder to the Plugins folder of your project.

If you have a C++ type project, add DTDMessaging to the list of dependency names in the <module_name>.Build.cs file of the module in which you plan to use the plugin.

Example:

PublicDependencyModuleNames.Add("DTDMessaging");

Android

Add your google-services.json file to the project's root directory. It will be used to configure notifications during the project-building process.

iOS

In the case your Unreal Engine is built from GitHub source code:

Enable notifications in the settings of your project: Edit → Project Settings → iOS → Enable Remote Notifications Support

In the case your Unreal Engine is not built from GitHub source code:

Add the parameter to the engine configuration file (<proj_dir>/Config/DefaultEngine.ini):

// Some code/Script/IOSRuntimeSettings.IOSRuntimeSettings]
bEnableRemoteNotificationsSupport=True

Data types

class UDTDMessagingBPLibrary

A class that implements analytic methods.

Header file:

#include "DTDMessaging/Public/DTDMessagingBPLibrary.h"

enum class EDTDNotificationActionType : uint8

Notification action type

Header file:

#include "DTDMessaging/Public/DTDNotificationActionType.h"

Values:

  • App = 0 - default value

  • Url = 1 - external link opening

  • Share = 2 - share contentc

  • DeepLink = 2 - an in-app link opening

struct FDTDNotification

Notification data container.

Header file:

#include "DTDMessaging/Public/DTDNotification.h"
MemberTypeDescription

ActionType

EDTDNotificationActionType

Тип действия уведомления

ActionString

FString

Идентификатор действия уведомления

Data

TMap<FString, FString>

Данные уведомления

struct FDTDNotificationAction

Notification action data container.

Header file:

#include "DTDMessaging/Public/DTDNotificationAction.h
MemberTypeDescription

ActionType

EDTDNotificationActionType

Тип действия уведомления

ActionString

FString

Идентификатор действия уведомления

ButtonId

FString

Идентификатор нажатой кнопки

ButtonText

FString

Текст нажатой кнопки

ButtonIcon

FString

Иконка нажатой кнопки

IsBackground

bool

Режим открытия приложения кнопкой

enum class EDTDIOSNotificationOptions : uint8

iOS only

Push Notification display settings are Bitflags that are managed by the developer and allow for selecting the method of user notification. It can be altered by the end user.

By default, it has the value: Badge|Sound|Alert

Header file:

#include "DTDMessaging/Public/DTDIOSNotificationOptions.h"

Values:

  • None = 0 - nothing

  • Badge = 1 << 0 - can display a badge on the app icon

  • Sound = 1 << 1 - can play a sound

  • Alert = 1 << 2 - can display an alert

  • CarPlay = 1 << 3 - can display a push notification on CarPlay

  • CriticalAlert = 1 << 4 - critical alerts can play a sound even if Do Not Disturb is enabled (critical alerts require a special entitlement issued by Apple). Available from iOS 12 onwards.

  • AppNotificationSettings = 1 << 5 - this option defines that the system should display a notification settings button in the app. Available from iOS 12.0 onwards.

  • Provisional = 1 << 6 - an option for sending provisional notifications to the Notification Center without interrupting functioning processes. Available from iOS 12.0 onwards.

Provisional - Provisional push notifications are shown in the User Notification Center but not on the lock screen. This type of push notification doesn’t require an explicit opt-in from the user. You can start sending them as soon as the user installs and launches your app. However, the user can also explicitly enable/disable your notifications.

Use this setting to avoid the permission request on app launch because it is seen as intrusive, and most users opt out of it.

It’s also important that when using the Provisional setting, the user needs to go to Notification Center settings to allow explicit notifications.

Delegates

Header file:

#include "DTDMessaging/Public/DTDMessagingDelegates.h"

Delegates:

DECLARE_DELEGATE_OneParam(FDTDMessagingBoolParamsDelegate, bool);
DECLARE_DELEGATE_OneParam(FDTDMessagingStringParamsDelegate, const FString&);
DECLARE_DELEGATE_OneParam(FDTDMessagingNotificationParamsDelegate, const FDTDNotification&);
DECLARE_DELEGATE_TwoParams(FDTDMessagingNotificationActionParamsDelegate, const FDTDNotification&, const FDTDNotificationAction&);

Initialization

Notification module initialization:

UDTDMessagingBPLibrary::Initialize();

Methods

SetAvailability

A method responsible for enabling/disabling push notifications. When the state changes, it sends an event that includes the availability status (true or false). The availability status flag is stored in the SDK.

UDTDMessagincgBPLibrary::SetAvailability(true);

GetAvailability

Get the current availability status flag (true or false):

ArgumentTypeDescription

onResult

  • FDTDMessagingDynamicBoolParamsDelegate

  • FDTDMessagingBoolParamsDelegate

Callback

auto onResult = new FDTDMessagingBoolParamsDelegate();
onResult->BindLambda([](bool value)
{
  // Your code...
});
UDTDMessagingBPLibrary::GetAvailability(*onResult);

GetToken

Get a current unique device ID used in the notification system:

ArgumentTypeDescription

onResult

  • FDTDMessagingDynamicStringParamsDelegate

  • FDTDMessagingStringParamsDelegate

Callback.

auto onResult = new FDTDMessagingStringParamsDelegate();
onResult->BindLambda([](const FString& value)
{
  // Your code...
});
UDTDMessagingBPLibrary::GetToken(*onResult);

SetTokenListener

Set a token listener. The listener will be executed when the SDK updates a unique device ID in the notification system.

ArgumentTypeDescription

listener

  • FDTDMessagingDynamicStringParamsDelegate

  • FDTDMessagingStringParamsDelegate

Listener.

auto listener = new FDTDMessagingStringParamsDelegate();
listener->BindLambda([](const FString& value)
{
  // Your code...
});
UDTDMessagingBPLibrary::SetTokenListener(*listener);

SetTokenErrorListener

Set a listener for errors in token reception. The listener will be executed when an error occurs while the SDK updates a unique device ID in the notification system.

ArgumentTypeDescription

listener

  • FDTDMessagingDynamicStringParamsDelegate

  • FDTDMessagingStringParamsDelegate

Listener.

auto listener = new FDTDMessagingStringParamsDelegate();
listener->BindLambda([](const FString& value)
{
  // Your code...
});
UDTDMessagingBPLibrary::SetTokenErrorListener(*listener);

SetNotificationReceiveListener

Set a listener for notification reception. The listener will be executed when the SDK receives a notification.

ArgumentTypeDescription

listener

  • FDTDMessagingDynamicNotificationParamsDelegate

  • FDTDMessagingNotificationParamsDelegate

Listener.

auto listener = new FDTDMessagingNotificationParamsDelegate();
listener->BindLambda([](const FDTDNotification& notification)
{
  // Your code...
});
UDTDMessagingBPLibrary::SetNotificationReceiveListener(*listener);

SetInvisibleNotificationReceiveListener

Set a listener for invisible notification reception. The listener will be executed when the SDK receives an invisible notification.

ArgumentTypeDescription

listener

  • FDTDMessagingDynamicNotificationParamsDelegate

  • FDTDMessagingNotificationParamsDelegate

Listener.

auto listener = new FDTDMessagingNotificationParamsDelegate();
listener->BindLambda([](const FDTDNotification& notification)
{
  // Your code...
});
UDTDMessagingBPLibrary::SetInvisibleNotificationReceiveListener(*listener);

SetNotificationActionListener

Set a listener for notification activation. The listener will be executed when the notification gets activated.

ArgumentTypeDescription

listener

  • FDTDMessagingDynamicNotificationActionParamsDelegate

  • FDTDMessagingNotificationActionParamsDelegate

Listener.

auto listener = new FDTDMessagingNotificationActionParamsDelegate();
listener->BindLambda([](const FDTDNotification& notification, const FDTDNotificationAction& action)
{
  // Your code...
});
UDTDMessagingBPLibrary::SetNotificationActionListener(*listener);

IOSSetNotificationOptions

iOS only

Set notification parameters.

ArgumentTypeDescription

options

int32

Options.

An int32 type value is used as an argument of this method. However, this argument should be calculated by using enumerators of EDTDIOSNotificationOptions and bitwise OR operator.

int32 options = EDTDIOSNotificationOptions::Badge |
  EDTDIOSNotificationOptions::Sound |
  EDTDIOSNotificationOptions::Alert;
UDTDMessagingBPLibrary::IOSSetNotificationOptions(options);

Last updated