Introducing the Notifications library for Windows 10!


The Notifications library from the UWP Community Toolkit allows you to generate tile, toast, and badge notifications in an object-oriented fashion, instead of directly dealing with messy XML. The library fully supports adaptive tiles/toasts and interactive toast notifications, and is officially built and maintained by the team at Microsoft who owns notifications. (This library was previously called NotificationsExtensions).

Quick Links

Quick Sample

Here’s a quick code snippet that shows you what the Notifications library gives you…

TileBindingContentAdaptive bindingContent = new TileBindingContentAdaptive()
{
    PeekImage = new TilePeekImage()
    {
        Source = "Assets/PeekImage.jpg"
    },

    Children =
    {
        new AdaptiveText()
        {
            Text = "Notifications library",
            HintStyle = AdaptiveTextStyle.Body
        },

        new AdaptiveText()
        {
            Text = "Generate notifications easily!",
            HintWrap = true,
            HintStyle = AdaptiveTextStyle.CaptionSubtle
        }
    }
};
<binding template="...">
  
  <image src="Assets/PeekImage.jpg" placement="peek" />
  
  <text hint-style="body">Notifications library</text>
  
  <text hint-style="captionSubtle" hint-wrap="True">Generate notifications easily!</text>
  
</binding>

Installing Notifications library

The easiest way to install the Notifications library is through NuGet. The package ID is “Microsoft.Toolkit.Uwp.Notifications“, the Author is Microsoft.

First, open the NuGet Package Manger inside your Visual Studio project.

And then search for either “uwp notifications” or “Microsoft.Toolkit.Uwp.Notifications” and install it.

Alternatively, you can clone the project from the GitHub page and then reference the projects yourself, if you so wish. But using NuGet is ridiculously easier. If you have any problems using this library through NuGet, please contact us through GitHub.

Getting Started

To learn how to use the Notifications library, please see our Adaptive Tiles Documentation and Adaptive/Interactive Toasts Documentation.

Comments (28)

  1. Abdusamad says:

    How can I add a system activation type to a toast with the NotificationsExtensions. I want to add a dismiss button, but I cant find a way to do so. The ActivationType enum only has Foreground, Background and Protocol as options.

  2. andrewbares7 says:

    @Abdusamad – I'm working on adding ToastButtonDismiss and ToastButtonSnooze, I forgot about those. I should have it done by EOD today (Aug 23rd), and the NuGet packages take around 5 hours to update, so you should be able to get the updated version through NuGet tomorrow.

  3. SilviuD says:

    I am looking for a way to display toasts when my Win 10 Universal app is minimized. The toasts do not need to be actioned (only click to hide them).

    Currently my toasts only get display if the app is in the foreground.

  4. andrewbares7 says:

    @Silviu – How are you sending the toasts when your app is minimized? Are you using ScheduledToastNotification? A background task? Push? When your app is minimized, your app's code likely becomes suspended, so you likely can't run any timers to send a normal toast notification.

  5. Abdusamad says:

    The update with ToastButtonDismiss and ToastButtonSnooze is live. Thanks. 🙂

  6. giuliofoletto says:

    When my app is closed and I click on a notification (for example a scheduled one, or an old one that's still in action center) I don't get to the page I want. I use the launch parameter and the OnActivated event in App.xaml.cs. If the app is running it works great, but if it's closed it just launches the app to a blank screen and does nothing. Could you provide an example of how to use OnActivated to get to a specific page of my app from a toast notification?

  7. giuliofoletto says:

    Nevermind, I think I managed to do it. I was lacking a Window.Current.Activate(); in my OnActivated override

  8. Abdussamad says:

    I have a bit of a problem with adding text to the lockscreen.

    I'm using the following code to create my tiles and lockscreenstatus:

               var content = new TileContent()

               {

                   Visual = new TileVisual()

                   {

                       TileMedium = mediumTileBinding,

                       TileWide = wideTileBinding,

                       TileLarge = largeTileBinding

                   }

               };

               content.Visual.LockDetailedStatus1 = "ExampleString1";

               content.Visual.LockDetailedStatus2 = "ExampleString2";

    The NotificationExtensions library apparently checks if such a string is already present in the TileWide content, if so adds an id to that text element instead of hint-lockDetailedStatus attribute to the binding element. A nice touch. For some reason only the first string ("ExampleString1") is shown though when the id attribute is added to the text elements. The second one isn't, unless I change it into something else which isn't already present in TileWide. But then the first string isn't shown. The only way to show both strings is to alter them both, but I want to show text which is already present on my TileWide.

  9. andrewbares7 says:

    @Abdussamad – Ah, I knew that optimization would bite me in the butt someday! Turns out if a text element is inside a group/subgroup, the lockscreen won't pick up its id. You must have had your second matching text string inside a group/subgroup, hence why it wasn't appearing.

    I've uploaded version 10240.0.4 of NotificationsExtensions.Win10 to NuGet. It should be live and available to install in a couple hours. It should fix your problem! Now it'll only assign the text ID if the text element is a direct <binding> child, so for your case, your second lock status will be placed using the hint-* attribute.

    The change is also already live on the library's GitHub if you're using that instead of NuGet. Thanks for reporting this issue!!

  10. Abdussamad says:

    Thank you!

  11. Aleksandr says:

    Please provide samples.

    how do we update our tile with the XML payload? What do we do with new TileContent() after we make it?

  12. andrewbares7 says:

    See the linked NotificationsExtensions documentation in the article, the Tile Notifications documentation page explains exactly that with code snippets: github.com/…/Tile-Notifications

    GetXml() will return a XmlDocument, which you then pass to the constructor of a new TileNotification object. Sending a tile notification remains unchanged from Windows 8.1, so you can use the existing 8.1 documentation to learn how to send the notification (it's different for push vs local).

    The only thing Windows 10 changes is the XML payload itself, and NotificationsExtensions allows you to generate the new XML payload. After that, it's all the same.

  13. Felix Chang says:

    I want to create a Secondary tile, pass tile id and launch by this Id, I don't find any example with NotificationsExtensions. Is is possible to achieve by NotificationsExtensions with adaptive template?  Thanks.

  14. Felix Zhang says:

    Thanks for your sharing. I want to user adaptive template to update secondary tile, like :

    var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileId);

    updater.Update(new TileNotification("adaptive templ content");

    But failed, do you have any ideas?

    Thanks for your help.

  15. andrewbares7 says:

    @Felix – Pinning a secondary tile and handling launches from it is unchanged from 8.1 – msdn.microsoft.com/…/hh868249.aspx You'll want to look at the OnLaunched method in your App.xaml.cs, which its arguments provide the tile ID that was clicked (and the tile's arguments).

    For updating a secondary tile, you can see our quick start for sending a tile notification. It covers both primary and secondary: blogs.msdn.com/…/sending-a-local-tile-notification-in-windows-10.aspx Essentially, get an XmlDocument from the TileContent object by using the GetXml() method and then construct a TileNotification from that.

  16. Felix Zhang says:

    Thanks for your replay.

    I can make it work according to your example, but still have some problems when I set the BackgroundImage. I found if the image is from local, it works, but it failed to update when the source is from network(http://…jpg). Do you have any ideas?

  17. andrewbares7 says:

    @Felix – Are you talking about the background image in the XML payload? As in…

    <image src="http://…jpg" placement="background"/>

    Or are you talking about the properties on the SecondaryTile itself, as in VisualElements.Square150x150Logo? Those properties only support local images (ms-appx or ms-appdata).

    However, images in your XML payload support http. Send us your XML payload so we can look at it. Alternatively, make sure you're using the "Notifications Visualizer" app to help debug tile notification issues like this. Search the app Store for it. It's a Windows 10 app.

  18. Felix Zhang says:

    Hi, I just change your example ("Quickstart-Sending-Local-Tile") secondary tile content with below content :

    TileContent content = new TileContent()

               {

                   Visual = new TileVisual()

                   {

                       TileMedium = new TileBinding()

                       {

                           Content = new TileBindingContentAdaptive()

                           {

                               BackgroundImage = new TileBackgroundImage() { Source = new TileImageSource("p4.music.126.net/…/3411784581323330.jpg) }

                           }

                       }

                   }

               };

               // Then create the tile notification

               var notification = new TileNotification(content.GetXml());

               // If the secondary tile is pinned

               if (SecondaryTile.Exists("MySecondaryTile"))

               {

                   // Get its updater

                   var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile("MySecondaryTile");

                   // And send the notification

                   updater.Update(notification);

               }

    it doesn't update the background image. I think it should be. If the background image is local file, it works.

    Thanks in advance.

  19. Felix Zhang says:

    Any feedback or help? I can see the tile is correct when it is in "Notifications Visualizer" , but I update it with the code above it failed.  I upload my demo but I cannot share the link, the system tell me my comment is spam…

  20. andrewbares7 says:

    @Felix – I'm looking into this. Seems like the tiles possibly don't like the domain "p4.music.126.net". They work fine with every other web image we've used (assuming the image is less than 200 KB in size). I'll update you when we figure out why that domain/URL is breaking.

  21. andrewbares7 says:

    @Felix – Looks like that website (p4.music.126.net) is sending back invalid HTTP headers.

    Their Last-Modified header is not in GMT time. It's currently this: "Last-Modified: Wed, 07 Oct 2015 11:50:18 CST"

    As per the w3.org HTTP standard, RFC2616, Section 3.3.1: "All HTTP date/time stamps MUST be represented in Greenwich Mean Time (GMT), without exception."

    Our tiles use WinHTTP which will fail because of this invalid header. So the website needs to be fixed. Do you have a way of contacting that website?

  22. Felix Zhang says:

    Thanks for you feed back. I am working for this company, I will report this issue, but I am not sure whether they will take care of this.

  23. Felix Zhang says:

    I am working on a music app for windows 10,  I want to show the song info in tile, do you have a sample about update tile in background, thanks

  24. andrewbares7 says:

    Hey Felix, see the Quickstart for sending a local tile notification: blogs.msdn.com/…/sending-a-local-tile-notification-in-windows-10.aspx

    You can use that code in the quickstart in your background task.

    One warning: For background audio tasks, you have to use the tile API's with the AppId overload. So if you're sending notifications to your primary tile, you would do…

    TileUpdateManager.CreateTileUpdaterForApplication("App").Update(notification);

    Notice that you pass in the AppId of "App" – unless you've manually edited your manifest, your app ID will also be "App". You have to do this since background audio tasks run in a separate app context than your normal app. Other types of background tasks don't have this issue since they run within your normal app context.

    Tell us if you have any more questions!

  25. Felix Zhang says:

    Nice feed, I have other issues related Windows 10, could you give some advice if you are convinient.

    1) Image memory leak: our apps have lots of image, we found the memory will be high when navigation between pages

    2) unknown crash: the app will crash without exception details and the call stack is only internall

    3) Sometimes it will throw Xaml parse failed, but we don't know the exactly reason, next time it works gain, nothing changs, it's really strange.

  26. andrewbares7 says:

    Felix, wish I could help you with those issues, but they're all outside of the scope of tiles and notifications. Please post a thread on the MSDN forums. I've also let the XAML team owner know about your issues. The MSDN forums are here: social.msdn.microsoft.com/…/home

  27. I built a Library for creating Cortana’s VCD file called CortanaExtensions (Inspired by NoticationsExtensions), It allows you to generate the VCD XML using C# code, which is very handy for Multilingual toolkit users, or people who don’t want to deal with XML.
    https://github.com/WilliamABradley/CortanaExtensions (NuGet Package linked on GitHub page)

    1. andrewbares7 says:

      Nice, that’s awesome William! If I ever get around to adding Cortana support to my personal apps, I’ll have to try out your extensions 🙂

Skip to main content