WSA Integration
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 the DTDMessaging
initialization block.
Attention! Use the #if UNITY_WSA
define to surround any notification module code on the WSA platform.
Use the following method to check current status:
The current module status will be sent to onGetMessagingEnabling
callback.
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:
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:
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:
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, add DevToDev.Background.ToastNotificationBackgroundTask
to the Entry Point field
.
Add Background Tasks in the Declarations tab and mark it as Push Notification
. After that, add DevToDev.Background.RawNotificationBackgroundTask
to the Entry Point field
.
To disable notifications, call the following method:
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