Windows (UWP)
WSA Integration
Module initialization
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: Unity Integration.
Add the
DTDAnalytics
initialization block after theDTDMessaging
initialization block.
Attention! Use the #if UNITY_WSA
define to surround any notification module code on the WSA platform.
Optional
Module status check
Use the following method to check current status:
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:
A complete example of notification module initialization:
External interface of the DTDMessaging module
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:
And at the end of of the App::OnLaunched(LaunchActivatedEventArgs^ e)
and App::OnActivated(IActivatedEventArgs^ args)
functions.
For Example:
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:
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:
Add Background Tasks in the Declarations tab and mark it as
System Event
. After that, addDevToDev.Background.ToastNotificationBackgroundTask
to theEntry Point field
.Add Background Tasks in the Declarations tab and mark it as
Push Notification
. After that, addDevToDev.Background.RawNotificationBackgroundTask
to theEntry Point field
.
Disabling
To disable notifications, call the following method:
Last updated