Adaptive and interactive toast notifications for Windows 10


Adaptive and interactive toast notifications are a new feature in Windows 10. They allow you to:

  • Create flexible toast notifications with more content and optional inline images without being limited to the previous “toast template catalog”.
  • Create interactive toast notifications that enable user interaction.

This documentation includes features added in Version 1607 of Windows 10. You can view the archived documentation for Windows 10 Version 1511.

To see the legacy templates from Windows 8.1 and Windows Phone 8.1, please see the legacy toast template catalog.

Overview

In Windows 10, we have updated the existing toast templates in several aspects:

  • Moved from a restricted template model to a flexible and adaptive template model;
  • Added ability to include buttons/inputs;
  • Provided 3 different activation types for the main toast notification and for each action;
  • Added ability to create a notification for specific scenarios, including alarm, reminder, and incoming call.

All of the above will be covered in this post.

Structure of toast notification

In Windows 10, developers construct a toast notification using XML, which should typically contain the following key elements:

  • <visual> which covers the content available for the users to visually see, including text and images;
  • <actions> which contains buttons/inputs the developer wants to add inside the notification;
  • <audio> which specifies the sound played when the notification pops.

Here is a quick example:

<toast launch="app-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Sample</text>
      <text>This is a simple toast notification example</text>
      <image placement="AppLogoOverride" src="oneAlarm.png" />
    </binding>
  </visual>
  <actions>
    <action content="check" arguments="check" imageUri="check.png" />
    <action content="cancel" arguments="cancel" />
  </actions>
  <audio src="ms-winsoundevent:Notification.Reminder"/>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Sample"
                },

                new AdaptiveText()
                {
                    Text = "This is a simple toast notification example"
                }
            },

            AppLogoOverride = new ToastGenericAppLogo()
            {
                Source = "oneAlarm.png"
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Buttons =
        {
            new ToastButton("check", "check")
            {
                ImageUri = "check.png"
            },

            new ToastButton("cancel", "cancel")
            {
                ImageUri = "cancel.png"
            }
        }
    },

    Audio = new ToastAudio()
    {
        Src = new Uri("ms-winsoundevent:Notification.Reminder")
    }
};

toast structure

Visual

Inside the visual element, you must have exactly one binding element, containing the visual contents of the toast.

Unlike tile notifications, which support multiple templates based on different tile sizes, toast notifications for Windows 10 UWP apps only have one template name – ToastGeneric. This has several advantages over the legacy template model which was a set of restricted templates.

  • Flexible. Developers can change the content of the toast, such as adding another line of text, adding an optional inline image, or change the thumbnail image from displaying the application icon to something else, without worrying about changing the entire template or creating an invalid payload due to template-name – content mismatch.
  • Adaptive. Developers can use the same code to construct the same payload for the toast notification that targets to deliver to different types of Windows devices, such as phone, tablet, desktop PC, or even Xbox – the different devices will accept the notification, and display it to the user under their own UI policies with appropriate visual affordance and interaction model.

For all the attributes supported in the visual section and its child elements, please see the Schema section below.

For more examples, please see Samples below.

Actions

In Windows 10 UWP apps, developers can add buttons/inputs to their toast notification, to empower the users to do more outside of the app. The actions are specified under the <actions> element. There are 2 types of elements a developer can specify:

  • <action>. This appears as a button on Desktop and Mobile. A developer can specify up to 5 custom or system actions inside a toast notification.
  • <input>. This allows users to provide input, like quick replying to a message or selecting an option from a drop down menu.

Note: Both <action> and <input> are adaptive within the Windows family. For example, in Windows Mobile or Desktop, an <action> to a user is a button to tap/click on. A text <input> is a textbox that user can input text with using keyboard or virtual keyboard. It is, however, very possible that in some future devices, an action is announced out by voice, and a text input from the user is taken by dictation – the notification’s interactivity will adapt to the interaction model and visual affordance of the device where the message is displayed on.

When an action is taken by the user, the developer can choose to do one of the following by specifying the activationType attribute inside <action>:

    • Activating the app in the foreground, with an action-specific argument that can be used to navigate to a specific page/context;
    • Activating the app’s background task without affecting the user;
    • Activating another app via protocol launch;
    • Specify a system action to perform. The current available system actions are snoozing and dismissing scheduled alarm/reminder, which will be further explained in a section below.

For all the attributes supported in <actions> section and its child elements, please see the Schema section below.

For an example of how interactive toasts work, please see the Samples below.

Audio

In Windows 10 UWP apps, the <audio> element remains unchanged compared to 8.1.

Mobile has always supported custom audio (ms-appx and ms-appdata), and Desktop added support for custom audio in Version 1511 (build 10586). Both can always use ms-winsoundevent. For more info on toast audio, see the audio schema page. And for sending custom audio toasts, see the quickstart.

Toast notifications for special scenarios

In Windows 10, a developer can use toast notifications for alarms, reminders, and incoming calls. These special toast notifications look visually consistent with the “standard” toast notifications, with some extra bits of UI policy that fits each scenario.

A reminder toast notification will stay on screen until the user dismisses it or takes action. On Windows Mobile, the reminder toast notifications will also show up pre-expanded.

In addition to sharing the above behaviors with reminder notifications, alarm notifications also automatically play looping audio.

Incoming call notifications are displayed full screen on Windows Mobile devices.

This is done by specifying the “scenario” attribute inside the root element of a toast notification – <toast>:

<toast scenario=” { default | alarm | reminder | incomingCall } ” >

XML Samples

Please note that all toast notification screenshots are taken from Desktop. The mobile version of the toast notifications are pre-collapsed depending on their scenario, with a grabber at the bottom to expand.

Notification with rich visual contents

You can have multiple lines of text, an optional small image to override the application logo, and an optional inline image thumbnail in a toast.

<toast launch="app-defined-string">
  <visual>
    <binding template="ToastGeneric">
	  <text>Photo Share</text>
      <text>Andrew sent you a picture</text>
      <text>See it in full size!</text>
	  <image src="https://unsplash.it/360/180?image=1043" />
      <image placement="appLogoOverride" src="https://unsplash.it/64?image=883" hint-crop="circle" />
    </binding>
  </visual>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Photo Share"
                },

                new AdaptiveText()
                {
                    Text = "Andrew sent you a picture"
                },

                new AdaptiveText()
                {
                    Text = "See it in full size!"
                },

                new AdaptiveImage()
                {
                    Source = "https://unsplash.it/360/180?image=1043"
                }
            },

            AppLogoOverride = new ToastGenericAppLogo()
            {
                Source = "https://unsplash.it/64?image=883",
                HintCrop = ToastGenericAppLogoCrop.Circle
            }
        }
    }
};

Notification with actions (sample 1)

<toast launch="app-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Microsoft Company Store</text>
      <text>New Halo game is back in stock!</text>
    </binding>
  </visual>
  <actions>
    <action activationType="foreground" content="See more details" arguments="details"/>
    <action activationType="background" content="Remind me later" arguments="later"/>
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Microsoft Company Store"
                },

                new AdaptiveText()
                {
                    Text = "New Halo game is back in stock!"
                }
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Buttons =
        {
            new ToastButton("See more details", "details"),

            new ToastButton("Remind me later", "later")
            {
                ActivationType = ToastActivationType.Background
            }
        }
    }
};

toast structure

Notification with actions (sample 2)

<toast launch="app-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Restaurant suggestion...</text>
      <text>We noticed that you are near Wasaki. Thomas left a 5 star rating after his last visit, do you want to try it?</text>
    </binding>
  </visual>
  <actions>
    <action activationType="foreground" content="Reviews" arguments="reviews" />
    <action activationType="protocol" content="Show map" arguments="bingmaps:?q=sushi" />
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Restaurant suggestion..."
                },

                new AdaptiveText()
                {
                    Text = "We noticed that you are near Wasaki. Thomas left a 5 star rating after his last visit, do you want to try it?"
                }
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Buttons =
        {
            new ToastButton("Reviews", "reviews"),

            new ToastButton("Show map", "bingmaps:?q=sushi")
            {
                ActivationType = ToastActivationType.Protocol
            }
        }
    }
};

toast structure

Notification with text input and actions (sample 1)

In this sample, you can add a textbox that allows the user to input text.

<toast launch="developer-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Andrew B.</text>
      <text>Shall we meet up at 8?</text>
      <image placement="appLogoOverride" src="https://unsplash.it/64?image=883" hint-crop="circle" />
    </binding>
  </visual>
  <actions>
    <input id="message" type="text" placeHolderContent="Type a reply" />
    <action activationType="background" content="Reply" arguments="reply" />
    <action activationType="foreground" content="Video call" arguments="video" />
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Andrew B."
                },

                new AdaptiveText()
                {
                    Text = "Shall we meet up at 8?"
                }
            },

            AppLogoOverride = new ToastGenericAppLogo()
            {
                Source = "https://unsplash.it/64?image=883",
                HintCrop = ToastGenericAppLogoCrop.Circle
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastTextBox("message")
            {
                PlaceholderContent = "Type a reply"
            }
        },

        Buttons =
        {
            new ToastButton("Reply", "reply")
            {
                ActivationType = ToastActivationType.Background
            },

            new ToastButton("Video call", "video")
            {
                ActivationType = ToastActivationType.Foreground
            }
        }
    }
};

toast structure

Notification with text input and actions (sample 2)

If allowing user to reply with text input is the only scenario you care about, you can also use the below layout. This only works if your action specifies an image icon.

<toast launch="developer-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Andrew B.</text>
      <text>Shall we meet up at 8?</text>
      <image placement="appLogoOverride" src="https://unsplash.it/64?image=883" hint-crop="circle" />
    </binding>
  </visual>
  <actions>
    <input id="message" type="text" placeHolderContent="Type a reply" />
    <action activationType="background" content="Reply" arguments="reply" hint-inputId="message" imageUri="Assets/Icons/send.png"/>
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Andrew B."
                },

                new AdaptiveText()
                {
                    Text = "Shall we meet up at 8?"
                }
            },

            AppLogoOverride = new ToastGenericAppLogo()
            {
                Source = "https://unsplash.it/64?image=883",
                HintCrop = ToastGenericAppLogoCrop.Circle
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastTextBox("message")
            {
                PlaceholderContent = "Type a reply"
            }
        },

        Buttons =
        {
            new ToastButton("Reply", "reply")
            {
                TextBoxId = "message",
                ImageUri = "Assets/Icons/send.png",
                ActivationType = ToastActivationType.Background
            }
        }
    }
};

toast structure

Notification with selection input and actions

In this sample, you can add a dropdown list with pre-defined selections for the user to select.

<toast launch="developer-defined-string">
  <visual>
    <binding template="ToastGeneric">
      <text>Spicy Heaven</text>
      <text>When do you plan to come in tomorrow?</text>
    </binding>
  </visual>
  <actions>
    <input id="time" type="selection" defaultInput="2" >
      <selection id="1" content="Breakfast" />
      <selection id="2" content="Lunch" />
      <selection id="3" content="Dinner" />
    </input>
    <action activationType="background" content="Reserve" arguments="reserve" />
    <action activationType="foreground" content="Call Restaurant" arguments="call" />
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Launch = "app-defined-string",

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Spicy Heaven"
                },

                new AdaptiveText()
                {
                    Text = "When do you plan to come in tomorrow?"
                }
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastSelectionBox("time")
            {
                DefaultSelectionBoxItemId = "2",
                Items =
                {
                    new ToastSelectionBoxItem("1", "Breakfast"),
                    new ToastSelectionBoxItem("2", "Lunch"),
                    new ToastSelectionBoxItem("3", "Dinner")
                }
            }
        },

        Buttons =
        {
            new ToastButton("Reserve", "reserve")
            {
                ActivationType = ToastActivationType.Background
            },

            new ToastButton("Call Restaurant", "call")
            {
                ActivationType = ToastActivationType.Foreground
            }
        }
    }
};

toast structure

Reminder Notification

Notifications with scenario “reminder” will appear pre-expanded and remain on the user’s screen till dismissed or interacted with.

<toast scenario="reminder" launch="action=viewEvent&amp;eventId=1983">
  
  <visual>
    <binding template="ToastGeneric">
      <text>Adaptive Tiles Meeting</text>
      <text>Conf Room 2001 / Building 135</text>
      <text>10:00 AM - 10:30 AM</text>
    </binding>
  </visual>

  <actions>
    
    <input id="snoozeTime" type="selection" defaultInput="15">
      <selection id="1" content="1 minute"/>
      <selection id="15" content="15 minutes"/>
      <selection id="60" content="1 hour"/>
      <selection id="240" content="4 hours"/>
      <selection id="1440" content="1 day"/>
    </input>

    <action activationType="system" arguments="snooze" hint-inputId="snoozeTime" content="" />

    <action activationType="system" arguments="dismiss" content=""/>
    
  </actions>
  
</toast>
ToastContent content = new ToastContent()
{
    Launch = "action=viewEvent&eventId=1983",
    Scenario = ToastScenario.Reminder,

    Visual = new ToastVisual()
    {
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = "Adaptive Tiles Meeting"
                },

                new AdaptiveText()
                {
                    Text = "Conf Room 2001 / Building 135"
                },

                new AdaptiveText()
                {
                    Text = "10:00 AM - 10:30 AM"
                }
            }
        }
    },

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastSelectionBox("snoozeTime")
            {
                DefaultSelectionBoxItemId = "15",
                Items =
                {
                    new ToastSelectionBoxItem("5", "5 minutes"),
                    new ToastSelectionBoxItem("15", "15 minutes"),
                    new ToastSelectionBoxItem("60", "1 hour"),
                    new ToastSelectionBoxItem("240", "4 hours"),
                    new ToastSelectionBoxItem("1440", "1 day")
                }
            }
        },

        Buttons =
        {
            new ToastButtonSnooze()
            {
                SelectionBoxId = "snoozeTime"
            },

            new ToastButtonDismiss()
        }
    }
};

toast structure

Handling foreground and background activation

To learn how to handle toast activations (the user clicking on your toast or buttons on the toast), see the Quicstart: Sending a local toast notifications and handling activations article.

Schema

Note: “?” means an attribute is optional

Section 1. <visual> and <audio>

<toast launch? duration? activationType? scenario? >
  <visual lang? baseUri? addImageQuery? >
    <binding template? lang? baseUri? addImageQuery? >
      <text lang? hint-maxLines? >content</text>
      <image src placement? alt? addImageQuery? hint-crop? />
      <group>
        <subgroup hint-weight? hint-textStacking? >
          <text />
          <image />
        </subgroup>
      </group>
    </binding>
  </visual>
  <audio src? loop? silent? />
</toast>
ToastContent content = new ToastContent()
{
    Launch = ?,
    Duration = ?,
    ActivationType = ?,
    Scenario = ?,

    Visual = new ToastVisual()
    {
        Language = ?,
        BaseUri = ?,
        AddImageQuery = ?,
        BindingGeneric = new ToastBindingGeneric()
        {
            Children =
            {
                new AdaptiveText()
                {
                    Text = ?,
                    Language = ?,
                    HintMaxLines = ?
                },

                new AdaptiveGroup()
                {
                    Children =
                    {
                        new AdaptiveSubgroup()
                        {
                            HintWeight = ?,
                            HintTextStacking = ?,
                            Children =
                            {
                                new AdaptiveText(),
                                new AdaptiveImage()
                            }
                        }
                    }
                },

                new AdaptiveImage()
                {
                    Source = ?,
                    AddImageQuery = ?,
                    AlternateText = ?,
                    HintCrop = ?
                }
            }
        }
    },

    Audio = new ToastAudio()
    {
        Src = ?,
        Loop = ?,
        Silent = ?
    }
};

Attributes in <toast>

launch?

launch? = string

This is an optional attribute.

A string that is passed to the application when it is activated by the toast. Depending on the value of activationType, this value can be received by the app in the foreground, inside the background task, or by another app that’s protocol launched from the original app.

The format and contents of this string are defined by the app for its own use. When the user taps or clicks the toast to launch its associated app, the launch string provides the context to the app that allows it to show the user a view relevant to the toast content, rather than launching in its default way.

[Note] If the activation is happened because user clicked on an action, instead of the body of the toast, the developer retrieves back the “arguments” pre-defined in that <action> tag, instead of “launch” pre-defined in the <toast> tag.

 

 

duration?

duration? = “short|long”

This is an optional attribute. Default value is “short”.

This attribute was introduced back in Windows 8 time-frame for specifying how long the toast notification stays on the screen – setting the value to “short” will make the notification display for  ~7 seconds and setting it to “long” will make the notification display for ~25 seconds. 

In Windows 10, developers have the following options to keep the notification on screen for longer than standard length (~7 seconds):

  • Specifying scenario attribute (see description below) to “alarm” or “reminder” to persist the notification on screen until the user dismisses it. 
  • Specify duration attribute to “long” while making sure the scenario attribute is specified to “default” or unspecified. This will result in the legacy behavior of notification showing on screen for ~25 seconds. 
    • We do not recommend using this property unless you have a good reason to keep the notification up for ~25 seconds on screen. This attribute exists mainly for appCompat reason. 

activationType?

activationType? = “foreground | background | protocol | system”

This is an optional attribute, default value is “foreground“.

scenario?

scenario? = “default | alarm | reminder | incomingCall”

This is an optional attribute, default value is “default”.

You do not need this unless your scenario is to pop an alarm, reminder, or incoming call. Do not use this just for keeping your notification persistent on screen.

Attributes in <visual>

lang?

Please see MSDN for details on these existing optional attributes.

baseUri?

Please see MSDN for details on these existing optional attributes.

addImageQuery?

Please see MSDN for details on these existing optional attributes.

 

Attributes in <binding>

template?

[Important] template? = “ToastGeneric”

If you are using any of the new adaptive and interactive notification features, please make sure you start using “ToastGeneric” template instead of the legacy template.

Using the legacy templates with the new actions might work now, but that is not the intended use case, and we cannot guarantee that will continue working.

lang?

Please see MSDN for details on these existing optional attributes.

baseUri?

Please see MSDN for details on these existing optional attributes.

addImageQuery?

Please see MSDN for details on these existing optional attributes.

 

Attributes in <text>

lang?

Please see MSDN for details on these existing optional attributes.

 

Attributes in <image>

src 

Please see MSDN

placement?

placement? = “inline” | “appLogoOverride”

This is optional.

This specifies where this image will be displayed.

“inline” means inside the toast body, below the text;

appLogoOverride” means replace the application icon (that shows up on the top left corner of the toast).

You can have up to 1 image for each placement value.

alt?

Please see MSDN.

addImageQuery?

Please see MSDN.

hint-crop?

hint-crop? = “none” | “circle”

This is optional.

none” is the default value which means no cropping.

circle” means cropping the image to a circular shape. Use this for profile images of a contact, image of a person, etc. as part of metro 2.0 design guidance.

 

Attributes in <audio>

src?

Please see MSDN.

loop?

Please see MSDN.

silent?

Please see MSDN.

Section 2. <actions>

<toast>
  <visual>
  </visual>
  <audio />
  <actions>
    <input id type title? placeHolderContent? defaultInput? >
      <selection id content />
    </input>
    <action content arguments activationType? imageUri? hint-inputId />
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Visual = ...

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastSelectionBox("id")
            {
                Title = ?
                DefaultSelectionBoxItemId = ?,
                Items =
                {
                    new ToastSelectionBoxItem("id", "content")
                }
            },

            new ToastTextBox("id")
            {
                Title = ?,
                PlaceholderContent = ?,
                DefaultInput = ?
            }
        },

        Buttons =
        {
            new ToastButton("content", "args")
            {
                ActivationType = ?,
                ImageUri = ?,
                TextBoxId = ?
            },

            new ToastButtonSnooze("content")
            {
                SelectionBoxId = "snoozeTime"
            },

            new ToastButtonDismiss("content")
        }
    }
};

Attributes in <input>

id

id = string

The id attribute is required and is used by developers to retrieve user inputs once the app is activated (in the foreground or background).

type

The type attribute is required.

type = “text | selection

It is used to specify a text input or input from a list of pre-defined selections.

On mobile and desktop, this is to specify whether you want a textbox input or a listbox input.

title?

title? = string

The title attribute is optional and is for developers to specify a title for the input for shells to render when there is affordance.

For mobile and desktop, this title will be displayed above the input.

placeHolderContent?

placeHolderContent? = string

The placeHolderContent attribute is optional and is the grey-out hint text for text input type. This attribute is ignored when the input type is not “text”.

defaultInput?

defaultInput? = string

The defaultInput attribute is optional and is used to provide a default input value.

If the input type is “text”, this will be treated as a string input;

If the input type is “selection”, this is expected to be the id of one of the available selections inside this input’s elements.

 

Attributes in <selection>

id

The id attribute is required. As a developer, you will use this id to identify which selection was selected by the user (the id is returned to your app).

content

The content attribute is required.

It provides the string to display for this selection element.

 

Attributes in <action>

content

content = string

The content attribute is required.

It provides the text string displayed on the button.

arguments

arguments = string

The arguments attribute describes the app-defined data that the app can later retrieve once it is activated from user taking this action.

activationType?

activationType? = “foreground | background | protocol | system
The activationType attribute is optional and the default value is “foreground”.

It describes what kind of activation this action will cause – foreground, background, or launching another app via protocol launch, or invoking a system action.

imageUri?

imageUri? = string

imageUri is optional and is used to provide an image icon for this action to display inside the button alone with the text content.

hint-inputId

hint-inputId = string

This is specifically used for the quick reply scenario.

The value needs to be the id of the input element desired to be associated with.

In mobile and desktop, this will put the button right next to the input box.

Section 3. Additional attributes for system handled actions.

In addition to the above sections, in Windows 10, we also provide system-handled actions for snoozing and dismissing notifications, for apps that do not want to handle the snoozing/rescheduling of these notifications inside their background task. The actions can be combined, or specified individually, but we do not recommend anyone implementing a snooze action without a dismiss action.

System commands combo – SnoozeAndDismiss

<toast>
  <visual>
  </visual>
  <actions hint-systemCommands="SnoozeAndDismiss" />
</toast>
ToastContent content = new ToastContent()
{
    Visual = ...

    Actions = new ToastActionsSnoozeAndDismiss()
};

Attributes in <actions>

hint-systemCommands?

WARNING: If you’re releasing a Mobile app, do NOT use this on TH1 and TH2 machines. hint-systemCommands is broken on Mobile and won’t allow the user to select a snooze time. Only use this if you’re only releasing your app on Desktop. If releasing an app on both, we recommend using the “Individual system handled actions” as seen below.

This has been fixed for Mobile RS1 builds 14273 and newer, and functions correctly.

This hint attribute will construct a dropbox for selecting snooze interval, a snooze action, and a dismiss action. The snooze and dismiss will all be handled by system (the app will not be activated when the user takes these actions).

The string displayed for the input and the 2 actions will be properly localized.

Individual system handled actions

<toast>
  <visual>
  </visual>
  <actions>
  <input id="snoozeTime" type="selection" defaultInput="10">
    <selection id="5" content="5 minutes" />
    <selection id="10" content="10 minutes" />
    <selection id="20" content="20 minutes" />
    <selection id="30" content="30 minutes" />
    <selection id="60" content="1 hour" />
  </input>
  <action activationType="system" arguments="snooze" hint-inputId="snoozeTime" content=""/>
  <action activationType="system" arguments="dismiss" content=""/>
  </actions>
</toast>
ToastContent content = new ToastContent()
{
    Visual = ...

    Actions = new ToastActionsCustom()
    {
        Inputs =
        {
            new ToastSelectionBox("snoozeTime")
            {
                DefaultSelectionBoxItemId = "15",
                Items =
                {
                    new ToastSelectionBoxItem("5", "5 minutes"),
                    new ToastSelectionBoxItem("10", "10 minutes"),
                    new ToastSelectionBoxItem("20", "20 minutes"),
                    new ToastSelectionBoxItem("30", "30 minutes"),
                    new ToastSelectionBoxItem("60", "1 hour")
                }
            }
        },

        Buttons =
        {
            new ToastButtonSnooze()
            {
                SelectionBoxId = "snoozeTime"
            },

            new ToastButtonDismiss()
        }
    }
};

To construct individual snooze and dismiss actions, you need to do the following:

  • Specify activationType = “system”.
  • Specify arguments = “snooze” | “dismiss”
  • Specify content:
    • If you want localized string of “snooze” and “dismiss” to be displayed on the actions, then specify content to be empty string – <action content = “”/>;
    • If you want your own customized string, just provide its value – <action content=”Remind me later” />.
  • Specify input:
    • If you do NOT want user to select a snooze interval, instead, just want your notification to snooze only once for a system-defined time interval (that is consistent across the OS), then do NOT construct any <input> at all;
    • If you want to provide selections of snooze interval:
      • Specify hint-inputId in the snooze action;
      • Make sure you match the id of the input with the hint-inputId of the snooze action – <input id=”snoozeTime”></input><action hint-inputId=”snoozeTime”/>
      • Specify id for selection to be a nonNegativeInteger which represent snooze interval in minutes – <selection id=”240” /> means snoozing for 4 hours;
      • Make sure that the value of defaultInput in <input> matches with one of the ids of the <selection> children elements.
      • Provide up to (but no more than) 5 <selection> values.

Comments (79)

  1. Anonymous says:

    Will there be a nuget library to facilitate these notifications? similar to the NotificationsExtensions package.

  2. Anonymous says:

    How can I call an xml file for a custom Toast by code?

  3. CabuxaMapache says:

    @FullMetal99012 (Editor update) Yes! NotificationsExtensions for Windows 10 is available and officially supported by Microsoft!

    (Original comment) You can use github.com/…/InteractiveToastExtensions

  4. leixu2046 says:

    @Fullmetal99012 As Cabuxa's comment mentioned, the official NotificationsExtensions for Windows 10 is now available through NuGet or GitHub.

    @Anrafu13 if you are also asking about extension library, please see if you may find the post below yours helpful. If you are asking about loading an existing xml file from your appx package, then please take a look at msdn.microsoft.com/…/windows.storage.storagefile.getfilefromapplicationuriasync.ASPX

  5. Harald Mühlhoff says:

    I'm trying to get the audio element with ms-appdata:/// to run under Windows 10 UWP (Desktop) but no luck so far. Tried the temp and the local folder. Has this feature made it into the release build? Is there a limit to the allowed length of the audio? Are there any special requirements with regards to the uri that don't exist with a MediaElement?

    Best regards,

    Harald

    http://www.carecom.de

    In Windows 10 UWP apps, the <audio> element remains unchanged compared to what’s currently supported for Windows Phone 8.1.

    You can now also provide a path to a local audio file in your app package or app storage, to play a custom sound specific for your app:

    ◾ms-appx:///

    ◾ms-appdata:///

  6. andrewbares7 says:

    @Harald – Looks like you're right, custom audio isn't working. We're investigating this issue. As of now, both ms-appx and ms-appdata don't work on Desktop, and only ms-appdata works on Mobile. Thanks for reporting this!

  7. Keuvain says:

    I am using the adaptive toast with a Win32 app, and I cannot manage to get my toast to stay in the action center when it timed out. If i close it with the close button, it goes in the action center but when let it time out, it just disappear.

    With the same toast (i used your first sample) in an Universal app, the toast stay in the action center when it timed out.

    Is it the expected behaviour for the win32 app ?

  8. leixu2046 says:

    @Keuvain Thanks for trying the new toast features. The default behavior for win32 apps should be the same in which the toast notifications are persisted in action center. We will investigate in the false behavior you are observing currently. Also, we will have some guidance and sample published soon on how to handle application activation from toast once it's inside action center using COM activation.

  9. Adrian says:

    How do you get a larger inline image like the reminder example?  I am unable to get anything other than a small cropped image like the first example. I'm sending the toast from a desktop program if that makes a difference.

  10. andrewbares7 says:

    @Adrian – For an inline image to display full width, the scenario attribute on the <toast> element needs to be set to either "reminder", "alarm", or "incomingCall".

    <toast scenario="reminder">
       ….
    </toast>

    However, do realize that the scenario changes other things. Those three scenarios will all force the notification to stay on screen until the user does something with it. Don't pick a scenario that conflicts with what your user expects (for example if a new text message used the reminder scenario, users would be annoyed that they're forced to dismiss the text message to continue doing anything on their device).

  11. Arun says:

    Hi, when i am trying to open the Background task from the action button in toast,  but i am getting an compilation error "the type or namespace "NotificationActionTriggerDetails" could not be found". Am i doing it in the right way.

    please help.

  12. Suresh says:

    I am running my windows 8 app in windows 10 machine. the problem i am facing is i am unable to get the LaunchActivatedEventArgs in launch event ?

    can anyone suggest the issue please ?

  13. Suresh says:

    Sorry for not providing full information for the above question.

    Windows 8 store app in windows 10 machine and the question is regarding the ToastNotification. when user taps on it.

  14. Brandon H_ says:

    One problem I'm seeing is that my notifications sometimes don't show up in the UI, but rather are sent to the Action Center. How can we avoid this and *always* show the Toast UI?? For example, I'd like to alert the user to the fact that a refresh has completed in my app via a toast notification

  15. Amer says:

    how I load xml file to XmlDocument?

  16. Suresh says:

    Is anyone facing the problem which i am facing ? please see the previous 5 comment from this comment.

  17. andrewbares7 says:

    @Suresh – Ah I see you did comment over here originally, great! Ok, so Windows 8 app running on Windows 10 no longer receives the LaunchActivatedEventArgs inside OnLaunched for toasts… That definitely sounds like a bug. Probably due to the fact that we've switched to using OnActivated as documented in this blog post… but Windows 8 apps SHOULD be grandfathered in… We'll investigate it. Thank you for reporting it!

    @Brandon – Toasts should always show up on-screen first before going into action center, unless the user changed their settings and disabled banners. You can check your settings on your PC by opening Settings -> System -> Notifications & Actions, and then clicking on your app, and confirming that "Show notification banners" is enabled. If it's enabled and toasts are still inconsistently appearing, please give us more info (sample app if you have one) and we can investigate further.

    @Amer – Even better, use the new NotificationsExtensions library so you don't have to generate XML! You can use IntelliSense and objects to create your notifications! blogs.msdn.com/…/introducing-notificationsextensions-for-windows-10.aspx  Alternatively, to load a string to XmlDocument, create a new XmlDocument, and then call .LoadXml(string);

  18. Abdusamad says:

    Has the issue with custom sound been fixed? And how will the fix be rolled out to users, via a regular Windows Update or in a new Windows 10 "build" update?

    Is it possible to have a notification play a long sound file (30 seconds to 1 minute)?

    I remember it wasn't possible in W(P) 8.1. I wanted to test it in a UWP app, but it didn't work and I found out in the comments here that there's a bug.

  19. opayen says:

    There is an error in the sample code: it's not NotificationActionTriggerDetails, it's ToastNotificationActionTriggerDetail.

  20. andrewbares7 says:

    @Suresh – I just tested a Windows 8.1 app on Windows 10 and the OnLaunched got triggered correctly, with the toast launch args. You're still having issues with that?

    @Abdusamad – Custom audio… We incorrectly thought that we supported custom audio on Desktop. Turns out that was cut, so audio has remained unchanged from Windows 8.1 (only mobile supports ms-appx and ms-appdata). However, there's new bugs affecting the mobile custom audio (ms-appx doesn't work, and also on "alarm" or "incomingCall" scenarios, neither ms-appdata nor ms-appx work). We're still working on fixing them, no update yet.

    @opayen – Thanks for pointing that out!! Updated the code snippet.

  21. Abdusamad says:

    Thank you for the replie(s on your blog). That's too bad. I have an app in the Windows Phone 8.1 store with almost 700 downloads and lots of users requesting a custom long notification sound (non looping). I'm in the process of porting the app to UWP Desktop/Tablet and Mobile and I'm a bit disappointed it still hasn't been implemented on the Windows platform.

    I hope it will be implemented soon because I think there's lots of developers and users who'd like that feature and it's basically the #1 requested feature for my app.

    Any news on the Tile Template Visualizer btw? Thanks again.

  22. andrewbares7 says:

    What's the longest audio file you've tried? And on the toast, you set duration="long"?

    Tile Template Visualizer is still pending approval to use the actual DLL from Start (otherwise it won't be 100% exact, only a visualization).

  23. Abdusamad says:

    The longest was 3:20. Duration="long" works doesn't work on WP 8.1. And on UWP I can't test with custom sound because it's buggy/not implemented yet, so that's my dilemma. Is there a different way to set source for custom sound other than ms-appx or ms-appdata?

    Thanks for the update. 🙂

  24. andrewbares7 says:

    ms-appdata works on Windows 10 Mobile, as long as you're not also using it while specifying "incomingCall" or "alarm". So you could try that.

    So you theoretically should be able to achieve it right now, assuming duration="long" works on Mobile now? I haven't tried that, as Lei's article says, we really were only keeping the "long" option around for app compat, so it's possible we didn't bring it to mobile.

  25. Suresh says:

    @andrewbares7 – sorry for the late reply. And thanks for answering.

    I have done a small mistake too. i solved the problem my self. Like in the blog he said toast launch args will be received in OnActivatedEvent i did the same in my app and we need to update the toast payload(toast xml) too. This toast payload will not work in windows 8 machine. it only works in windows 10 machines.

    In windows 10 machine toast notifications will be received even though the app in running in the foreground.

    thanks once again for this good blog.

  26. leixu2046 says:

    @suresh thanks a lot for trying these new features out, and yes, the new toast payload does not work in Windows 8 machine since the old parser wouldn't recognize the new stuff we came up with.

    Apologize for missing your previous questions but I'm glad Andrew helped out. Please do reach out if you have more questions.

  27. John Preston says:

    @leixu2046 "The default behavior for win32 apps should be the same in which the toast notifications are persisted in action center."

    I've implemented usage of new toast notifications in Telegram Desktop messaging app and the notifications disappear from Action Center as soon as they disappear from screen (or as soon as the action center is closed, if it was opened while the notification was still on the screen). It is a bad behavior and many users have complained about this.

    May I have any information about that issue? Was it reproduced in MS? Will it be fixed by a Windows Update, or it will persist that way much longer? I'm interested in any information about that.

  28. John Preston says:

    Also I've got some problems with per-app notification settings, there are no apps listed, but I use one my own custom app with notifications and one downloaded from the Store, both sending notifications, which could be seen here: updates.tdesktop.com/…/noapps.png

    How can I get my win32 app to that list? Why I don't have any apps there and how this could be fixed?

  29. Lindsay Mathieson says:

    Where can I find a list of the protocols that can be launched? specifically I'd like to launch the default browser to an url, but arguments="http://www.slashdot.com&quot; doesn't work.

  30. andrewbares7 says:

    @John – I've told Lei to follow up with you.

    @Lindsay – The available URI launch protocols can be seen here: msdn.microsoft.com/…/mt228340.aspx They're the same that are supported with LaunchUriAsync. Launching websites works, just tested it on my personal RTM laptop. Make sure that you're setting activationType="protocol". Tell us what's happening and maybe we can help you. For example, the following payload generates a toast with a button that, when clicked, opens Slashdot.

    <toast>

     <visual>

       <binding template='ToastGeneric'>

         <text>HTTP Toast</text>

       </binding>

     </visual>

     <actions>

       <action activationType="protocol" arguments="http://www.slashdot.com&quot; content="Open SlashDot"/>

     </actions>

    </toast>

  31. Brandon Paddock says:

    How do I send a toast notification that works on both Windows 10 and Windows/WP 8.1? I've tried adding two <visual> elements, but this leads to Win10 just displaying "New notification" and not any of the actual notification content. If I send just the 8.1 or just the Win10 <visual> it works. But I need to send both because users may be using a mix of devices (especially Win10 PCs with 8.1 phones since Win10 Mobile isn't out yet).

  32. Half baked toast says:

    There is ToastNotification.Activated event which provides ToastActivatedEventArgs and it does not contains UserInput property while Application.OnActivated event provides ToastNotificationActivatedEventArgs which contains UserInput property. Why windows is losing information in ToastNotificationActivated event?

    Is there a way i can get the UserInput property in ToastNotification.Activated event?

  33. andrewbares7 says:

    @Half baked toast – Is there a reason you're using the Activated event on the toast object instead of the OnActivated method? Please tell us your scenario so you can help. If the user taps on your toast from within action center, that Activated event will NOT fire.

    We recommend using the OnActivated method, since the Activated event isn't useful for most scenarios. For example, what happens when the user clicks on your toast after they've closed your app? The Activated event won't be able to trigger. But OnActivated method does.

  34. Half baked toast says:

    @andrewbares7 – I'm raising the toast notification from a dll and want to handle the toast events in that dll only. The application is not a UWP app and I don't want any event if the application is closed. Since there is no Application class so I don't have the Application.OnActivated method.

    When the ToastNotification.Activated event can handle the most of the scenarios of toast notification like button click on notification, cancel and timeout, why UserInput is not available in that event?

  35. andrewbares7 says:

    @Brandon – Unfortunately there's no good solution for sending a single payload that supports both 8.1 and the new features of 10. You would have to store on your server what OS the device is on, and then send the correct payload.

    @Half baked – I've told Lei to follow up with you about Win32 apps. He's working on a blog post that covers this.

  36. AC says:

    I am using the a win32 app, and I cannot manage to get my toast to stay in the action center when it timed out.

    With the same toast in an Universal app, the toast stay in the action center when it timed out.

    Is it the expected behaviour ?

    Also – how to handle application activation from toast once it's inside action center?

  37. Dat Nguyen says:

    defaultSelection or defaultInput… ?

    I think defaultInput is righ, not defaultSelection

  38. leixu2046 says:

    @AC Hi AC, check out this blog post on how win32 apps can send and handle toast notifications in Windows 10:

    http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx

  39. andrewbares7 says:

    @Dat Nguyen – Thanks for reporting that mistake! You're correct, it should be defaultInput. I've updated the article.

  40. Abdusamad says:

    @andrewbares7 – Is there any update on ms-appx support for custom audio? Or custom audio for Desktop?

    I've implemented custom audio for Windows 10 Mobile using ms-appdata, but it doesn't work on my Lumia 520 with Insider Preview. I have a method (in app.xaml.cs) that fires after first install or an update, which copies the sound file to the appdata folder so I can use it for custom audio, but when I launch the app the first time, it gets to the splashscreen and closes. So I think something goes wrong when copying the file. I haven't been able to reproduce this on the emulators, it works fine there. I dont know if it's a Insider Preview issue or what. Still trying to figure it out. Being able to use ms-appx would be a lot more efficient, since I won't have to copy the file.

  41. andrewbares7 says:

    @Abdusamad – ms-appx for mobile should be fixed in the latest mobile preview. I'll test it tomorrow on internal builds. You can assume that it'll work in the final release of mobile.

    Desktop custom audio is not being added at this time.

    1. Hi,
      Can’t use ms-appx and ms-appdata to set source for ToastAudio on Desktop. I see it’s an old trouble.
      Last comment was almost a year ago.
      Are there any updates or fixes?

  42. Abdusamad says:

    Just tested on Mobile build 10572, ms-appx works. 🙂 Thanks.

  43. Kiran says:

    @leixu2046 "The default behavior for win32 apps should be the same in which the toast notifications are persisted in action center."

    Is there any update on this?

    In win32 app, My Toast notification is vanished from Action center after time out.

    But I need it to be persisted until user responds to it.

    is there any workaround for it?

  44. andrewbares7 says:

    @Kiran – See our new post on how to send toast notifications from Win32 apps: blogs.msdn.com/…/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx

    You'll have to set up a COM server, as that article describes, so that your app can be activated from toasts persisted in Action Center. Otherwise, if you didn't have that COM server, and the user closed your app, and then the user clicked the persisted toast, the toast wouldn't do anything (your Activated event that was registered as a callback is no longer active since your code isn't running).

    Sorry for not replying to your comment. Thanks for nagging us, we're happy to help!

  45. Methew says:

    I cant get quick reply scenario working properly, I mean button local icon/image never shows, from web works nice.

  46. andrewbares7 says:

    @Methew – How are you referencing your local images? Are you using ms-appx:/// with three slashes? A copy of the XML you're using, in addition to a screenshot of your Visual Studio project's file structure (specifically showing the path of the image you're referencing) would be helpful. Local images definitely work, we've used them before.

  47. AYC says:

    I am using a win8 app, and I cannot manage to get my toast to stay in the action center when it expired.

    With the same toast in an Universal app, the toast stay in the action center when it timed out.

    Is it the expected behaviour ?

    Also – how to handle application activation from toast once it's inside action center?

  48. andrewbares7 says:

    @AYC – Are you actually talking about *Win32* apps? If so, then you have to read the documentation for Win32, since this post is about UWP apps. The Win32 documentation is here: blogs.msdn.com/…/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx

  49. rudyhuyn says:

    Note:

    One important step is missing if you want to uses a background task:

    You need to register the background agent first:

    BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync();

    BackgroundTaskBuilder builder = new BackgroundTaskBuilder()

    {

    Name = "ToastAgent",

    TaskEntryPoint = "Task.ToastAgent"

    };

    builder.SetTrigger(new ToastNotificationActionTrigger());

    BackgroundTaskRegistration registration = builder.Register();

  50. andrewbares7 says:

    Thanks Rudy for that important code snippet of registering the background task, which we forgot! I've moved all this code to the Quickstart and added the registeration step, and simply made this page link to it so there's no redundant information: blogs.msdn.com/…/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10.aspx

  51. Chourouk says:

    this is a sample that works for tile notifications 😀

    code.msdn.microsoft.com/Tile-notifications-in-e217d57f

  52. Elena says:

    I have precisely the same issue as Half baked toast and I totally support his question.

    @andrewbares7 Are you guys working on that blog post still?

  53. andrewbares7 says:

    Hey Elena, you're talking about Win32 apps? We have a blog post for that (blogs.msdn.com/…/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx). There are a number of open issues that Lei is trying to address with Win32.

    If you're writing a UWP, we explain how to handle activation in this Quickstart: blogs.msdn.com/…/quickstart-sending-a-local-toast-notification-and-handling-activations-from-it-windows-10.aspx

  54. Elena says:

    Hey, Andrew, thanks for your swift reply. Yes, I am talking about Win32 apps. The blog post you gave me unfortunately does not solve my problem. I've already left some comments there as well. Can we find out what are the "open issues" that Lei is trying to address? This would be extremely helpful.

    1. Alexis Menard says:

      I second the comments here about the UserInput missing in ToastActivatedEventArgs . Most of us gets that indeed without the Activate event we won’t be able to have persistent notifications working in the notification center but right now in order for us to move slowly to full UWP apps we have to extract and put as much as possible into a DLL with .NET code that is used by the old school app to slowly port the code base. Notifications is a must have these days and really have the UserInput field would already be a good step to have good notifications support. Then of course in the future we can have full persistent notifications with activations that launch the app. The fact that some of us uses .NET in that secondary DLL library is https://github.com/WindowsNotifications/NotificationsExtensions which is pretty good to construct the notifications.

      https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10/ is a good start to have some support of the ActivatedEvent but again there is no sample somewhere ready to test. It would be appreciated to have one.

      Thanks for the work.

  55. Daniel says:

    I remember I was really happy to see your post because I’ve been looking for how to get user input from toast notification.
    Thanks for this post.

    But I have a big problem with getting user input from toast notification when user types text in Korean.
    I’m showing user toast notification including input and User may type their reply to the toast input box and click reply action button then my background task receives ToastNotificationActionTriggerDetail.
    But the UserInput value set in ToastNotificationActionTriggerDetail includes only empty string, “”, if the input text is “ㅋㅋ”, “ㅎㅎ” or “ㅇㅇ” those are the most popular abbreviations used on chat message in Korea.
    They are similar “kk”, “hh” or “IC” in English.

    It seemed the toast input box cannot get these Korean text above because it recognizes text input is not completed yet.
    It’s just my opinion from my experience and I’d like to hear your advice.

    1. andrewbares7 says:

      Hey Daniel, I can’t seem to repro your issue. I popped a toast using a text box, and pasted in “ㅋㅋ”, and I successfully got back that same text in the UserInput values.

      What device (Mobile or Desktop) and what build are you seeing this issue on? I tried it on Desktop TH2, where it seemed to work.

      1. Daniel says:

        It has been fixed at RS1 timeline.
        Thanks for the thought.

  56. Vero says:

    Our current balloon notification implementation is WPF, and the issue we are observing is that when the user uses Win 10 where they automatically get converted to Toast Notification (OS Controls it) is text is cut for some languages in the desktop environment. If we use the legacy (Win 7) balloon notification in Windows 10, there is no as such character limitation in the balloon pop-up. What is the character limitation for toast in the desktop environment?

    1. andrewbares7 says:

      Hey Vero!

      There’s no specific character limit on toasts, since different devices might be able to display different amounts of text (and also different languages have different character sizes). Also, we’re slightly changing how toast notifications look and feel in new versions of Windows 10, which affects how many characters would be displayed.

      For your scenario, you should make sure that the user can click the toast to read the full content, so that if the content couldn’t all fit, when they click the toast, they can see everything.

  57. Rocky says:

    I am facing two issues with Toast notification with Desktop application on Windows 10

    1) When user does nothing with the toast, it simply disappear without going to the action center (ToastNotification.Dismissed is ToastDismissalReason.TimedOut). It is not sticky, how do I make it work?

    2) Chasing the notification is also not working, I have Activated event, tapping on the toast notification does not do anything. Consider after generating notification my application will not be running. But I have created a shortcut under Users Start menu Program using AppuserModelID concept, and It is the same AppID used while creating the notification.

    1. andrewbares7 says:

      Hi Rocky, sounds like you’re talking about Win32 Desktop apps, not UWP. Please bring your conversation over to the Win32 article: https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10/

      And for (1), toasts are temporary, after a few seconds, they’ll go into Action Center.

  58. Elena says:

    When the number of notifications in Action Center exceeds 20, I get an extra notification saying “More notifications”. If I click on it, my app opens and all the other 20 toasts from Action Center disappear. I wasn’t able to find any documentation on this. Can you please tell me if this is expected behavior?

  59. James says:

    Is there any XSD file available for the Toast XML schema? It can be used for the XML data binding for my backend.

    1. andrewbares7 says:

      Hey James! No, we haven’t published an XSD for the Toast XML schema. If you’re using C# on your backend, you could use NotificationsExtensions to generate your notifications rather than using raw XML.

  60. Roman says:

    Hello!
    How to implementation action events in powershell script?

    1. andrewbares7 says:

      Hey Roman, I’m not sure what you mean… Powershell scripts? This article is about Windows 10 UWP apps.

      1. Roman says:

        I use powershell script to send toast notification and it works, but there is no way to intercept the events and add EventHandler with objects of WinRT classes.

  61. Charly says:

    The MSDN documentation regarding the src attribute of the image element says that among other protocols both the http:// and the https:// protocol are supported. However, when using such an URI (example: src=”https://en.wikipedia.org/static/apple-touch/wikipedia.png”), the image is not displayed in the toast. Downloading the same file locally and using the file:///-protocol (like “file:///C:\images\wikipedia.png”) works as expected.

    Is the MSDN documentation outdated regarding the supported protocols? Was the http://- and https:// protocol support dropped from Windows 8(.1) to Windows 10? If so, was this done on purpose? Or is that a bug? Do Windows 10 toasts still support images from foreign http:// or https:// sources?

    1. andrewbares7 says:

      Hey Charly, sorry for the late reply, I think email notifications once again were turned off for some reason :/

      http:// and https:// images are supported for UWP’s. Sounds like maybe you’re writing a Win32 app? Win32 apps do not support http images, since they do not have the package manifest like a UWP containing the internet capability. Hence for Win32 apps, you need to download the image and then reference it via file://.

      Thanks!
      Andrew

  62. Charlemagne says:

    Hi,

    I got problem on toast activated.
    I used activated method to show the form but after a few seconds the form is gone and it was not even disposed.
    How to prevent this on happening?

    Thanks

  63. Raj Kappor says:

    I have a question related to ToastGeneric template “Text” element.
    Is there a character size limit for each “text” element only 40 , 60 etc.
    If there is any how to increase this limit ?
    Please give any pointers or details on this.
    Thanks Rajesh

    1. andrewbares7 says:

      Hey Rajesh! Nope, there’s no limits on the character lengths of elements (nor are there limits on URI’s, etc).

      However, the entire XML payload must be less than 5 KB. Therefore, you’ll want to make sure to trim your strings at reasonable lengths. Maybe 500 chars max of text on the toast? Or if you’re using multiple text elements, maybe 200 chars per each text element? You’ll want to take into consideration other parts of your payload too, like the launch args, buttons, etc… everything adds up, and you’ll need to keep it under 5 KB.

  64. JohnnyC says:

    Hi!

    I have a Win32 application and I’ve noticed that when I tap/click the toast to acknowledge it, the focus doesn’t get properly set to my main application (in my toast handler I say MainWindow.Activate() or something similar). I see my application come up, but keyboard focus is not on it. Should i be doing something different?

    1. JohnnyC says:

      it seems on toast acknowledge ShellExperienceHost.exe gets focus… and it can’t be taken away unless a physical mouse click or tap touches another application.

      1. JohnnyC says:

        Well for what it’s worth I’ve filed a connect bug with a patch file to apply to the github project to reproduce the issue. I’m pretty sure it’s a Win10 bug as on 8.1 this same type of behaviour of putting focus on an element after toast click works fine.

        https://connect.microsoft.com/VisualStudio/feedback/details/3119759/setting-keyboard-focus-on-an-application-after-win-10-toast-acknowledgement-is-broken-by-shellexperiencehost-exe

        1. andrewbares7 says:

          Thanks Johnny, I’ve sent this info to our Win32 dev expert!

Skip to main content