locked
Push notification for Universal Windows Platform RRS feed

  • Question

  • I would like to implement a push notification for my uwp and when it's clicked, it will launch my program and send a parammeter of type string so that I can read it and print it on my application.

    I see the tutorial here, but it's using xaml : http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/07/02/adaptive-and-interactive-toast-notifications-for-windows-10.aspx

    Is there any way for doing that using c# dynamically? or even better, can I use JavaScript instead?

    Friday, October 30, 2015 12:26 PM

Answers

  • Doesn't know anything about using JavaScript, but we can use C# to generate xaml template for interactive toast  notification using NotificationExtension ( https://github.com/anbare/NotificationsExtensions/wiki).

    The notification extensions library allows us to generate tile,tost and badge notification in an object-oriented fashion, instead of directly deadling with messy XML.

    Saturday, October 31, 2015 1:40 AM

All replies

  • Doesn't know anything about using JavaScript, but we can use C# to generate xaml template for interactive toast  notification using NotificationExtension ( https://github.com/anbare/NotificationsExtensions/wiki).

    The notification extensions library allows us to generate tile,tost and badge notification in an object-oriented fashion, instead of directly deadling with messy XML.

    Saturday, October 31, 2015 1:40 AM
  • Hey Popo,

    You need to specify the launch attribute on your toast notification XML payload. And then when the user clicks your toast, the text inside the launch attribute is provided in the OnActivated method of your App.xaml.cs page. To see how to do this, and a working code sample, read Quickstart: Sending a local toast and handling activations. Note that while that Quickstart is sending a toast locally, a lot of the same code applies to a push notification. You still generate the same XML payload in both cases. And you handle activation in the same way.

    As Puja said, you can use NotificationsExtensions to generate the XML payload via C#. NotificationsExtensions works from servers in addition to UWP apps, just install the NuGet package. If you have a UWP JavaScript app, you can also use NotificationsExtensions (it's built as a Windows Runtime Component so JavaScript and C# and C++ apps can call it). If you want to use PHP on your server, you can construct the XML payload manually (the Quickstart provides "Vanilla" examples that illustrate what the raw XML looks like).

    • Proposed as answer by andrewbares7 Thursday, November 5, 2015 7:28 PM
    Thursday, November 5, 2015 7:28 PM