LogoLogo
My AppsLive demoNewsArticles
  • Introduction
  • 📌Product updates: 2025
    • 2024
    • 2023
  • Getting Started
    • Registration
    • Adding a space
    • Adding an app to the space
  • Basic Events & Custom Events
  • Integration
    • Expert Tips
      • What to track
      • Payments & Anti-cheat
      • Check your integration
    • Integration of SDK 2.0+
      • SDK Integration
        • Android
        • iOS
        • macOS
        • Windows
        • Web
          • Web SDK Integration
          • Web SDK Releases
        • Unity
        • Unreal Engine
        • Godot Engine
      • Automatic payment tracking
        • App Store
        • Google Play
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anticheat methods
        • Track sessions
      • Push notifications
        • Android
        • iOS
        • Windows (UWP)
        • Unity
          • Android
          • iOS
          • Windows (UWP/WSA)
        • Unreal Engine
      • A/B testing
        • Description of A/B testing on the SDK side
        • Working with A/B tests in the devtodev interface
        • A/B testing examples
    • Integration of SDK 1.0+ (deprecated)
      • SDK Integration
        • iOS
        • Android
        • Windows 8.1 and 10
        • Web
        • Unity
        • Mac OS
        • Adobe Air
        • UE4
      • Setting up Events
        • Basic methods
        • Secondary methods
        • User profile
        • Anti-cheat Methods
      • Push Notifications
        • IOS
        • Android
        • Windows 8.1 and Windows 10
        • Unity
        • Abode Air
        • UE4
    • Test Devices
    • Server API
      • Data API 2.0
      • Subscription API
      • Push API
        • IOS
        • Android
        • Windows UWP
        • Windows
      • Raw Export
      • Labels API
      • Data API
    • Import historical data via API
    • Data Export
      • Data Export to Cloud Storage (BigQuery / Amazon S3)
  • 3rd Party Sources
    • Attribution Trackers
      • AppsFlyer
      • Adjust
      • Branch.io
      • Kochava
      • Tenjin
      • Tune (MAT)
      • Singular
      • Custom postback API
      • Facebook Ads referral decryption
    • App Marketplace Data
      • App Store Connect Stats
      • App Store Subscriptions
      • Google Play Console Stats
      • Google Play Subscriptions
      • AppGallery Connect Stats
    • Ad revenue
      • AdColony
      • AdMob
      • Facebook
      • MoPub
      • Unity Ads
      • Vungle
      • Ad revenue API
    • Cohort export
  • Reports and Functionality
    • Space-related Reports and Functionality
      • Overview
      • Custom dashboards & Reports
      • SQL
        • SQL tips
        • SQL Query examples
      • Audience overlap
    • Project-related Reports and Functionality
      • Overview
        • Real-Time Dashboard
        • Acquisition reports
        • Engagement reports
        • Monetization reports
        • In-game analysis reports
        • Cohort analysis
      • Reports
      • Push Notifications
        • Android Notifications
        • IOS Notifications
        • Windows Notifications
        • Button Templates
      • Predictions
      • Users & Segments
      • Filters
      • A/B Testing
      • Tuning
      • Settings
  • Metrics and Glossary
    • Ad networks metrics
    • Market Metrics
    • Prediction Metrics
    • SDK Metrics
    • Subscription metrics
  • Space Management
  • User Profile Management
  • Limits
  • Scenarios and Best Practices
    • Analytics use cases
    • Match-3
    • MMORPG Games
    • Hyper-Casual games
    • Social Casino
    • RPG games
    • Farming games
    • Non-gaming app
  • FAQ
    • Identification
    • Raw Data
    • All about data discrepancies
  • Slack
Powered by GitBook
On this page
  • Module initialization
  • Optional
  • External interface of the DTDMessaging module
  • Build a Windows Store App in Unity
  • Disabling

Was this helpful?

Export as PDF
  1. Integration
  2. Integration of SDK 2.0+
  3. Push notifications
  4. Unity

Windows (UWP/WSA)

WSA Integration

PreviousiOSNextUnreal Engine

Last updated 21 days ago

Was this helpful?

Module initialization

  1. For the Messaging module to function you need the basic Analytics package. Before the notification initialization, you need to initialize the SDK. More about it you can read here: .

  2. Add the DTDAnalytics initialization block after the DTDMessaging initialization block.

#if UNITY_WSA
  DTDMessaging.WSA.SetMessagingEnabling(true);
#endif#

Attention! Use the #if UNITY_WSA define to surround any notification module code on the WSA platform.

#if UNITY_WSA
  DTDMessaging.WSA.{AnyMethod}
#endif#

Optional

Module status check

Use the following method to check current status:

void GetMessagingEnabling(Action<bool> onGetMessagingEnabling)

The current module status will be sent to onGetMessagingEnabling callback.

Listening to events

You can listen to basic events of the Messaging module: create the class that implements the IDTDPushListener interface and send it to the DTDMessaging.WSA.SetPushListener method.

Class example:

public class MyPushListener : IDTDPushListener
{
    public void OnPushServiceRegistrationSuccessful(string deviceId)
    {
        Debug.Log(deviceId);
    }

    public void OnPushServiceRegistrationFailed(string error)
    {
        Debug.Log(error);

    }

    public void OnPushNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnInvisibleNotificationReceived(DTDPushMessage message)
    {
        //IOS only.
    }

    public void OnPushNotificationOpened(DTDPushMessage pushMessage, DTDActionButton actionButton)
    {
        Debug.Log(pushMessage.ToString());
        Debug.Log(actionButton.ToString());
    }
}

A complete example of notification module initialization:

public class MyPushListener : IDTDPushListener
{
    public void OnPushServiceRegistrationSuccessful(string deviceId)
    {
        Debug.Log(deviceId);
    }

    public void OnPushServiceRegistrationFailed(string error)
    {
        Debug.Log(error);
    }

    public void OnPushNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnInvisibleNotificationReceived(DTDPushMessage message)
    {
        Debug.Log(message);
    }

    public void OnPushNotificationOpened(DTDPushMessage pushMessage, DTDActionButton actionButton)
    {
        Debug.Log(pushMessage.ToString());
        Debug.Log(actionButton.ToString());
    }
}

public class NotificationExample : MonoBehaviour
{
    private const string APP_KEY = "***************"
    void Start()
    {
        DTDAnalytics.Initialize(APP_KEY);
#if UNITY_WSA
        DTDMessaging.WSA.SetPushListener(new PushListener());
        DTDMessaging.WSA.SetMessagingEnabling(true);
#endif
    }
}

External interface of the DTDMessaging module

Method
Description

void DTDMessaging.WSA.SetMessagingEnabling(bool value)

The method responsible for enabling or disabling of the push notification module

void DTDMessaging.WSA.GetMessagingEnabling(Action<bool> onGetMessagingEnabling)

The method that returns current state of the push notification module to onGetMessagingEnabling callback

void DTDMessaging.WSA.SetPushListener (IDTDPushListener pushListener)

It sets a listener for push notification event trapping

Build a Windows Store App in Unity

Build a Windows Store App in Unity. After the app is built, a Visual Studio project will be created. Proceed with the following changes.

There is a difference in the implementation of the elements mentioned below for different types of projects:

IL2CPP + XAML

Put the following source in your App class (usually it is App.xaml.cpp file). Add several lines of code in a generated App.xaml.cpp class. After defining headers:

//...headers

extern "C" __declspec(dllimport) void __stdcall AddActivatedEventArgs(IInspectable* activatedEventArgs);

And at the end of of the App::OnLaunched(LaunchActivatedEventArgs^ e) and App::OnActivated(IActivatedEventArgs^ args) functions.

For Example:

void App::OnActivated(IActivatedEventArgs^ args) 
{
 //...other code
 AddActivatedEventArgs(reinterpret_cast<IInspectable*>(static_cast<Platform::Object^>(args)));
}

void App::OnLaunched(LaunchActivatedEventArgs^ e) 
{
 auto args = static_cast<IActivatedEventArgs^>(e);
 AddActivatedEventArgs(reinterpret_cast<IInspectable*>(static_cast<Platform::Object^>(args)));
}

IL2CPP + D3D

Put the following source in your App class (usually it is App.cpp file). Add several lines of code in a generated App.cpp class. After defining headers:

//...headers
extern "C" __declspec(dllimport) void __stdcall AddActivatedEventArgs(IInspectable* activatedEventArgs);
void App::OnActivated(CoreApplicationView^ sender, IActivatedEventArgs^ args) 
{
 //...other code
 AddActivatedEventArgs(reinterpret_cast<IInspectable*>(static_cast<Platform::Object^>(args)));
}

And at the end of of the App::OnActivated(CoreApplicationView^ sender, IActivatedEventArgs^ args) function.

Besides, in the UI editor of the Package.appxmanifest file you need to do the following:

  1. Add Background Tasks in the Declarations tab and mark it as System Event. After that, add DevToDev.Background.ToastNotificationBackgroundTask to the Entry Point field.

  2. Add Background Tasks in the Declarations tab and mark it as Push Notification. After that, add DevToDev.Background.RawNotificationBackgroundTask to the Entry Point field.

Disabling

To disable notifications, call the following method:

DTDMessaging.WSA.SetMessagingEnabling(false);
Unity Integration