Windows (UWP)
Push Notifications (UWP)
The DevToDev.Messaging
package necessary for notifications is available in the NuGet
package manager.
1. NuGet Installation
Package Manager UI
Find the DevToDev.Messaging
package using the package manager search engine and click Install. The latest version of the package is recommended.
2. Credentials
To integrate WNS, you need to get the Package SID and Application Secret Key from the Microsoft Partner Center and specify them in the devtodev push notification settings (Project -> Settings-> Push notifications):
3. Setup
For the correct package functioning, add handlers invoke to the Windows.UI.Xaml.Application
class implementation.
Besides, in the UI editor of the Package.appxmanifest file do the following:
Add Background Tasks to the Declarations tab and mark it as System Event. After that enter
DevToDev.Background.ToastNotificationBackgroundTask
to the Entry Point field.Add Background Tasks to the Declarations tab and mark it as Push Notification. After that enter
DevToDev.Background.RawNotificationBackgroundTask
to the Entry Point field.
4. Initialization
For the DevToDev.Messaging
package functioning you need to have the main DevToDev.Analytics
package installed. Initialize the SDK before initializing messages. You can read about it in more detail in the SDK initialization section.
After the SDK has been initialized you can move to initializing messages. To do this, call the method:
5. Events
It is possible to listen to events from the DevToDev.Messaging
package:
1. Push Token - a string that allows to identify the client on a remote server for sending him customized notifications. For listening the unique Push Token ID issue event, it is necessary to be subscribed to the event:
2. To track the errors related to the unique Push Token ID issue, it is necessary to be subscribed to the event:
Where error is a string value containing information about the error.
3. To handle incoming message data, it is necessary to be subscribed to the following event:
Where messageData
belongs to the IDictionary<string, string>
type and contains data sent from the server together with the message.
4. To handle notification activation events, it is necessary to be subscribed to the event:
Where messageAction
is DevToDev.Messaging.DTDMessageAction
class instance:
6. Disabling
Call the method to turn notifications off:
Last updated