Toast Result Code 43

broken image


-->

This site contains user submitted content, comments and opinions and is for informational purposes only. Apple may provide or recommend responses as a possible solution based on the information provided; every potential issue may involve several factors not detailed in the conversations captured in an electronic forum and Apple can therefore provide no guarantee as to the. Our code sample will use this package. At the end of the article we'll provide the 'plain' code snippets that don't use any NuGet packages. This package allows you to create toast notifications without using XML. Step 2: Add namespace declarations. Windows.UI.Notifications includes the toast APIs.

A toast notification is a message that your app can construct and deliver to your user while they are not currently inside your app.

This quickstart walks you through the steps to create, deliver, and display a Windows 10 toast notification using rich content and interactive actions. This quickstart uses local notifications, which are the simplest notification to implement. All types of apps (WPF, UWP, WinForms, console) can send notifications!

Important

If you're writing a C++ app, please see the C++ UWP or C++ WRL documentation.

Step 1: Install NuGet package

Within your Visual Studio solution, right click your project, click 'Manage NuGet Packages.' and search for and install the Microsoft.Toolkit.Uwp.NotificationsNuGet package version 7.0 or greater.

Important

.NET Framework desktop apps that still use packages.config must migrate to PackageReference, otherwise the Windows 10 SDKs won't be referenced correctly. In your project, right-click on 'References', and click 'Migrate packages.config to PackageReference'.

.NET Core 3.0 WPF apps must update to .NET Core 3.1, otherwise the APIs will be absent.

Our code sample will use this package. This package allows you to create toast notifications without using XML, and also allows desktop apps to send toasts.

Step 2: Send a toast

In Windows 10, your toast notification content is described using an adaptive language that allows great flexibility with how your notification looks. For more information, see the toast content documentation.

We'll start with a simple text-based notification. Construct the notification content (using the Notifications library), and show the notification! Note that the namespace is Microsoft.Toolkit.Uwp.Notifications.

Etcher bootable usb. Try running this code and you should see the notification appear!

Step 3: Handling activation

After showing a notification, you likely need to handle the user clicking the notification (whether that means bringing up specific content after the user clicks it, opening your app in general, or performing an action when the user clicks the notification).

The steps for handling activation differ for UWP, Desktop (MSIX), and Desktop (unpackaged) apps.

When the user clicks your notification (or a button on the notification with foreground activation), your app's App.xaml.csOnActivated will be invoked, and the arguments you added will be returned.

App.xaml.cs

Important

You must initialize your frame and activate your window just like your OnLaunched code. OnLaunched is NOT called if the user clicks on your toast, even if your app was closed and is launching for the first time. We often recommend combining OnLaunched and OnActivated into your own OnLaunchedOrActivated method since the same initialization needs to occur in both.

First, in your Package.appxmanifest, add:

  1. Declaration for xmlns:com
  2. Declaration for xmlns:desktop
  3. In the IgnorableNamespaces attribute, com and desktop
  4. desktop:Extension for windows.toastNotificationActivation to declare your toast activator CLSID (using a new GUID of your choice).
  5. MSIX only: com:Extension for the COM activator using the GUID from step #4. Be sure to include the Arguments='-ToastActivated' so that you know your launch was from a notification

Package.appxmanifest

Then, in your app's startup code (App.xaml.cs OnStartup for WPF), subscribe to the OnActivated event.

When the user clicks any of your notifications (or a button on the notification), the following will happen.

If your app is currently running.

  1. The ToastNotificationManagerCompat.OnActivated event will be invoked on a background thread.

If your app is currently closed.

  1. Your app's EXE will be launched and ToastNotificationManagerCompat.WasCurrentProcessToastActivated() will return true to indicate the process was started due to a modern activation and that the event handler will soon be invoked.
  2. Then, theToastNotificationManagerCompat.OnActivated event will be invoked on a background thread.

When the user clicks any of your notifications (or a button on the notification), the following will happen.

If your app is currently running.

  1. The ToastNotificationManagerCompat.OnActivated event will be invoked on a background thread.

If your app is currently closed.

  1. Your app's EXE will be launched and ToastNotificationManagerCompat.WasCurrentProcessToastActivated() will return true to indicate the process was started due to a modern activation and that the event handler will soon be invoked.
  2. Then, theToastNotificationManagerCompat.OnActivated event will be invoked on a background thread.

In your app's startup code (App.xaml.cs OnStartup for WPF), subscribe to the OnActivated event.

Step 4: Handling uninstallation

You don't need to do anything! When UWP apps are uninstalled, all notifications and any other related resources are automatically cleaned up.

You don't need to do anything! When MSIX apps are uninstalled, all notifications and any other related resources are automatically cleaned up.

If your app has an uninstaller, in your uninstaller you should call ToastNotificationManagerCompat.Uninstall();. If your app is a 'portable app' without an installer, consider calling this method upon app exit unless you have notifications that are meant to persist after your app is closed.

The uninstall method will clean up any scheduled and current notifications, remove any associated registry values, and remove any associated temporary files that were created by the library.

Adding images

You can add rich content to notifications. We'll add an inline image and a profile (app logo override) image.

Note Family feud generator.

Images can be used from the app's package, the app's local storage, or from the web. As of the Fall Creators Update, web images can be up to 3 MB on normal connections and 1 MB on metered connections. On devices not yet running the Fall Creators Update, web images must be no larger than 200 KB.

Important

Http images are only supported in UWP/MSIX/sparse apps that have the internet capability in their manifest. desktop non-MSIX/sparse apps do not support http images; you must download the image to your local app data and reference it locally.

Adding buttons and inputs

You can add buttons and inputs to make your notifications interactive. Buttons can launch your foreground app, a protocol, or your background task. We'll add a reply text box, a 'Like' button, and a 'View' button that opens the image.

The activation of foreground buttons are handled in the same way as the main toast body (your App.xaml.cs OnActivated will be called).

Note that arguments added to the top-level toast (like conversation ID) will also be returned when the buttons are clicked, as long as buttons use the AddArgument API as seen above (if you custom assign arguments on a button, the top-level arguments won't be included).

Handling background activation

When you specify background activation on your toast (or on a button inside the toast), your background task will be executed instead of activating your foreground app.

For more information on background tasks, please see Support your app with background tasks.

If you are targeting build 14393 or higher, you can use in-process background tasks, which greatly simplify things. Note that in-process background tasks will fail to run on older versions of Windows. We'll use an in-process background task in this code sample.

Then in your App.xaml.cs, override the OnBackgroundActivated method. You can then retrieve the pre-defined arguments and user input, similar to the foreground activation.

App.xaml.cs

For desktop applications, background activations are handled the same as foreground activations (your OnActivated event handler will be triggered). You can choose to not show any UI and close your app after handling activation.

Set an expiration time

In Windows 10, all toast notifications go in Action Center after they are dismissed or ignored by the user, so users can look at your notification after the popup is gone.

However, if the message in your notification is only relevant for a period of time, you should set an expiration time on the toast notification so the users do not see stale information from your app. For example, if a promotion is only valid for 12 hours, set the expiration time to 12 hours. In the code below, we set the expiration time to be 2 days.

Note

The default and maximum expiration time for local toast notifications is 3 days.

Provide a primary key for your toast

If you want to programmatically remove or replace the notification you send, you need to use the Tag property (and optionally the Group property) to provide a primary key for your notification. Then, you can use this primary key in the future to remove or replace the notification.

To see more details on replacing/removing already delivered toast notifications, please see Quickstart: Managing toast notifications in action center (XAML).

Toast Result Code 430

Tag and Group combined act as a composite primary key. Group is the more generic identifier, where you can assign groups like 'wallPosts', 'messages', 'friendRequests', etc. And then Tag should uniquely identify the notification itself from within the group. By using a generic group, you can then remove all notifications from that group by using the RemoveGroup API.

Clear your notifications

Apps are responsible for removing and clearing their own notifications. When your app is launched, we do NOT automatically clear your notifications.

Windows will only automatically remove a notification if the user explicitly clicks the notification.

Here's an example of what a messaging app should do…

  1. User receives multiple toasts about new messages in a conversation
  2. User taps one of those toasts to open the conversation
  3. The app opens the conversation and then clears all toasts for that conversation (by using RemoveGroup on the app-supplied group for that conversation)
  4. User's Action Center now properly reflects the notification state, since there are no stale notifications for that conversation left in Action Center.

To learn about clearing all notifications or removing specific notifications, see Quickstart: Managing toast notifications in action center (XAML).

Resources

Toast Result Code 433

-->

The following describes all of the properties and elements within toast content.

If you would rather use raw XML instead of the Notifications library, please see the XML schema.

  • ToastVisual
    • ToastBindingGeneric

ToastContent

ToastContent is the top level object that describes a notification's content, including visuals, actions, and audio.

PropertyTypeRequiredDescription
LaunchstringfalseA string that is passed to the application when it is activated by the Toast. 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.
VisualToastVisualtrueDescribes the visual portion of the toast notification.
ActionsIToastActionsfalseOptionally create custom actions with buttons and inputs.
AudioToastAudiofalseDescribes the audio portion of the toast notification.
ActivationTypeToastActivationTypefalseSpecifies what activation type will be used when the user clicks the body of this Toast.
ActivationOptionsToastActivationOptionsfalseNew in Creators Update: Additional options relating to activation of the toast notification.
ScenarioToastScenariofalseDeclares the scenario your toast is used for, like an alarm or reminder.
DisplayTimestampDateTimeOffset?falseNew in Creators Update: Override the default timestamp with a custom timestamp representing when your notification content was actually delivered, rather than the time the notification was received by the Windows platform.
HeaderToastHeaderfalseNew in Creators Update: Add a custom header to your notification to group multiple notifications together within Action Center.

ToastScenario

Specifies what scenario the toast represents.

ValueMeaning
DefaultThe normal toast behavior.
ReminderA reminder notification. This will be displayed pre-expanded and stay on the user's screen till dismissed.
AlarmAn alarm notification. This will be displayed pre-expanded and stay on the user's screen till dismissed. Audio will loop by default and will use alarm audio.
IncomingCallAn incoming call notification. This will be displayed pre-expanded in a special call format and stay on the user's screen till dismissed. Audio will loop by default and will use ringtone audio.

ToastVisual

The visual portion of toasts contains the bindings, which contains text, images, adaptive content, and more.

PropertyTypeRequiredDescription
BindingGenericToastBindingGenerictrueThe generic toast binding, which can be rendered on all devices. This binding is required and cannot be null.
BaseUriUrifalseA default base URL that is combined with relative URLs in image source attributes.
AddImageQuerybool?falseSet to 'true' to allow Windows to append a query string to the image URL supplied in the toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of 'www.website.com/images/hello.png' given in the notification becomes 'www.website.com/images/hello.png?ms-scale=100&ms-contrast=standard&ms-lang=en-us'
LanguagestringfalseThe target locale of the visual payload when using localized resources, specified as BCP-47 language tags such as 'en-US' or 'fr-FR'. This locale is overridden by any locale specified in binding or text. If not provided, the system locale will be used instead.

ToastBindingGeneric

The generic binding is the default binding for toasts, and is where you specify the text, images, adaptive content, and more.

PropertyTypeRequiredDescription
ChildrenIListfalseThe contents of the body of the Toast, which can include text, images, and groups (added in Anniversary Update). Text elements must come before any other elements, and only 3 text elements are supported. If a text element is placed after any other element, it will either be pulled to the top or dropped. And finally, certain text properties like HintStyle aren't supported on the root children text elements, and only work inside an AdaptiveSubgroup. If you use AdaptiveGroup on devices without the Anniversary Update, the group content will simply be dropped.
AppLogoOverrideToastGenericAppLogofalseAn optional logo to override the app logo.
HeroImageToastGenericHeroImagefalseAn optional featured 'hero' image that is displayed on the toast and within Action Center.
AttributionToastGenericAttributionTextfalseOptional attribution text which will be displayed at the bottom of the toast notification.
BaseUriUrifalseA default base URL that is combined with relative URLs in image source attributes.
AddImageQuerybool?falseSet to 'true' to allow Windows to append a query string to the image URL supplied in the toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of 'www.website.com/images/hello.png' given in the notification becomes 'www.website.com/images/hello.png?ms-scale=100&ms-contrast=standard&ms-lang=en-us'
LanguagestringfalseThe target locale of the visual payload when using localized resources, specified as BCP-47 language tags such as 'en-US' or 'fr-FR'. This locale is overridden by any locale specified in binding or text. If not provided, the system locale will be used instead.

IToastBindingGenericChild

Marker interface for toast child elements that include text, images, groups, and more.

Implementations
AdaptiveText
AdaptiveImage
AdaptiveGroup
AdaptiveProgressBar

AdaptiveText

An adaptive text element. If placed in the top level ToastBindingGeneric.Children, only HintMaxLines will be applied. But if this is placed as a child of a group/subgroup, full text styling is supported.

PropertyTypeRequiredDescription
Textstring or BindableStringfalseThe text to display. Data binding support added in Creators Update, but only works for top-level text elements.
HintStyleAdaptiveTextStylefalseThe style controls the text's font size, weight, and opacity. Only works for text elements inside a group/subgroup.
HintWrapbool?falseSet this to true to enable text wrapping. Top-level text elements ignore this property and always wrap (you can use HintMaxLines = 1 to disable wrapping for top-level text elements). Text elements inside groups/subgroups default to false for wrapping.
HintMaxLinesint?falseThe maximum number of lines the text element is allowed to display.
HintMinLinesint?falseThe minimum number of lines the text element must display. Only works for text elements inside a group/subgroup.
HintAlignAdaptiveTextAlignfalseThe horizontal alignment of the text. Only works for text elements inside a group/subgroup.
LanguagestringfalseThe target locale of the XML payload, specified as a BCP-47 language tags such as 'en-US' or 'fr-FR'. The locale specified here overrides any other specified locale, such as that in binding or visual. If this value is a literal string, this attribute defaults to the user's UI language. If this value is a string reference, this attribute defaults to the locale chosen by Windows Runtime in resolving the string.

BindableString

A binding value for strings.

PropertyTypeRequiredDescription
BindingNamestringtrueGets or sets the name that maps to your binding data value.

AdaptiveTextStyle

Text style controls font size, weight, and opacity. Subtle opacity is 60% opaque.

ValueMeaning
DefaultDefault value. Style is determined by the renderer.
CaptionSmaller than paragraph font size.
CaptionSubtleSame as Caption but with subtle opacity.
BodyParagraph font size.
BodySubtleSame as Body but with subtle opacity.
BaseParagraph font size, bold weight. Essentially the bold version of Body.
BaseSubtleSame as Base but with subtle opacity.
SubtitleH4 font size.
SubtitleSubtleSame as Subtitle but with subtle opacity.
TitleH3 font size.
TitleSubtleSame as Title but with subtle opacity.
TitleNumeralSame as Title but with top/bottom padding removed.
SubheaderH2 font size.
SubheaderSubtleSame as Subheader but with subtle opacity.
SubheaderNumeralSame as Subheader but with top/bottom padding removed.
HeaderH1 font size.
HeaderSubtleSame as Header but with subtle opacity.
HeaderNumeralSame as Header but with top/bottom padding removed.

AdaptiveTextAlign

Bo advanced warfare. Controls the horizontal alignmen of text.

ValueMeaning
DefaultDefault value. Alignment is automatically determined by the renderer.
AutoAlignment determined by the current language and culture.
LeftHorizontally align the text to the left.
CenterHorizontally align the text in the center.
RightHorizontally align the text to the right.

AdaptiveImage

An inline image.

PropertyTypeRequiredDescription
SourcestringtrueThe URL to the image. ms-appx, ms-appdata, and http are supported. As of the Fall Creators Update, web images can be up to 3 MB on normal connections and 1 MB on metered connections. On devices not yet running the Fall Creators Update, web images must be no larger than 200 KB.
HintCropAdaptiveImageCropfalseNew in Anniversary Update: Control the desired cropping of the image.
HintRemoveMarginbool?falseBy default, images inside groups/subgroups have an 8px margin around them. You can remove this margin by setting this property to true.
HintAlignAdaptiveImageAlignfalseThe horizontal alignment of the image. Only works for images inside a group/subgroup.
AlternateTextstringfalseAlternate text describing the image, used for accessibility purposes.
AddImageQuerybool?falseSet to 'true' to allow Windows to append a query string to the image URL supplied in the toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of 'www.website.com/images/hello.png' given in the notification becomes 'www.website.com/images/hello.png?ms-scale=100&ms-contrast=standard&ms-lang=en-us'

AdaptiveImageCrop

Specifies the desired cropping of the image.

ValueMeaning
DefaultDefault value. Cropping behavior determined by renderer.
NoneImage is not cropped.
CircleImage is cropped to a circle shape.

AdaptiveImageAlign

Specifies the horizontal alignment for an image.

ValueMeaning
DefaultDefault value. Alignment behavior determined by renderer.
StretchImage stretches to fill available width (and potentially available height too, depending on where the image is placed).
LeftAlign the image to the left, displaying the image at its native resolution.
CenterAlign the image in the center horizontally, displayign the image at its native resolution.
RightAlign the image to the right, displaying the image at its native resolution.

AdaptiveGroup

New in Anniversary Update: Groups semantically identify that the content in the group must either be displayed as a whole, or not displayed if it cannot fit. Groups also allow creating multiple columns.

PropertyTypeRequiredDescription
ChildrenIListfalseSubgroups are displayed as vertical columns. You must use subgroups to provide any content inside an AdaptiveGroup.

AdaptiveSubgroup

New in Anniversary Update: Subgroups are vertical columns that can contain text and images.

PropertyTypeRequiredDescription
ChildrenIListfalseAdaptiveText and AdaptiveImage are valid children of subgroups.
HintWeightint?falseControl the width of this subgroup column by specifying the weight, relative to the other subgroups.
HintTextStackingAdaptiveSubgroupTextStackingfalseControl the vertical alignment of this subgroup's content.

IAdaptiveSubgroupChild

Marker interface for subgroup children.

Implementations
AdaptiveText
AdaptiveImage

AdaptiveSubgroupTextStacking

TextStacking specifies the vertical alignment of content.

ValueMeaning
DefaultDefault value. Renderer automatically selects the default vertical alignment.
TopVertical align to the top.
CenterVertical align to the center.
BottomVertical align to the bottom.

AdaptiveProgressBar

New in Creators Update: A progress bar. Only supported on toasts on Desktop, build 15063 or newer.

Toast Result Code 43
PropertyTypeRequiredDescription
Titlestring or BindableStringfalseGets or sets an optional title string. Supports data binding.
Valuedouble or AdaptiveProgressBarValue or BindableProgressBarValuefalseGets or sets the value of the progress bar. Supports data binding. Defaults to 0.
ValueStringOverridestring or BindableStringfalseGets or sets an optional string to be displayed instead of the default percentage string. If this isn't provided, something like '70%' will be displayed.
Statusstring or BindableStringtrueGets or sets a status string (required), which is displayed underneath the progress bar on the left. This string should reflect the status of the operation, like 'Downloading.' or 'Installing.'

AdaptiveProgressBarValue

A class that represents the progress bar's value.

PropertyTypeRequiredDescription
ValuedoublefalseGets or sets the value (0.0 - 1.0) representing the percent complete.
IsIndeterminateboolfalseGets or sets a value indicating whether the progress bar is indeterminate. If this is true, Value will be ignored.

BindableProgressBarValue

A bindable progress bar value.

Toast Result Code 43 Years

PropertyTypeRequiredDescription
BindingNamestringtrueGets or sets the name that maps to your binding data value.

ToastGenericAppLogo

A logo to be displayed instead of the app logo.

PropertyTypeRequiredDescription
SourcestringtrueThe URL to the image. ms-appx, ms-appdata, and http are supported. Http images must be 200 KB or less in size.
HintCropToastGenericAppLogoCropfalseSpecify how you would like the image to be cropped.
AlternateTextstringfalseAlternate text describing the image, used for accessibility purposes.
AddImageQuerybool?falseSet to 'true' to allow Windows to append a query string to the image URL supplied in the toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of 'www.website.com/images/hello.png' given in the notification becomes 'www.website.com/images/hello.png?ms-scale=100&ms-contrast=standard&ms-lang=en-us'

ToastGenericAppLogoCrop

Controls the cropping of the app logo image.

ValueMeaning
DefaultCropping uses the default behavior of the renderer.
NoneImage is not cropped, displayed square.
CircleImage is cropped to a circle.

ToastGenericHeroImage

A featured 'hero' image that is displayed on the toast and within Action Center.

PropertyTypeRequiredDescription
SourcestringtrueThe URL to the image. ms-appx, ms-appdata, and http are supported. Http images must be 200 KB or less in size.
AlternateTextstringfalseAlternate text describing the image, used for accessibility purposes.
AddImageQuerybool?falseSet to 'true' to allow Windows to append a query string to the image URL supplied in the toast notification. Use this attribute if your server hosts images and can handle query strings, either by retrieving an image variant based on the query strings or by ignoring the query string and returning the image as specified without the query string. This query string specifies scale, contrast setting, and language; for instance, a value of 'www.website.com/images/hello.png' given in the notification becomes 'www.website.com/images/hello.png?ms-scale=100&ms-contrast=standard&ms-lang=en-us'

ToastGenericAttributionText

Attribution text displayed at the bottom of the toast notification.

PropertyTypeRequiredDescription
TextstringtrueThe text to display.
LanguagestringfalseThe target locale of the visual payload when using localized resources, specified as BCP-47 language tags such as 'en-US' or 'fr-FR'. If not provided, the system locale will be used instead.

IToastActions

Marker interface for toast actions/inputs.

Implementations
ToastActionsCustom
ToastActionsSnoozeAndDismiss

ToastActionsCustom

Implements IToastActions

Create your own custom actions and inputs, using controls like buttons, text boxes, and selection inputs.

PropertyTypeRequiredDescription
InputsIListfalseInputs like text boxes and selection inputs. Only up to 5 inputs are allowed.
ButtonsIListfalseButtons are displayed after all the inputs (or adjacent to an input if the button is used as a quick reply button). Only up to 5 buttons are allowed (or fewer if you also have context menu items).
ContextMenuItemsIListfalseNew in Anniversary Update: Custom context menu items, providing additional actions if the user right clicks the notification. You can only have up to 5 buttons and context menu items combined.

IToastInput

Marker interface for toast inputs.

Implementations
ToastTextBox
ToastSelectionBox

ToastTextBox

Implements IToastInput

A text box control that the user can type text into.

PropertyTypeRequiredDescription
IdstringtrueThe Id is required, and is used to map the user-inputted text into a key-value pair of id/value which your app later consumes.
TitlestringfalseTitle text to display above the text box.
PlaceholderContentstringfalsePlaceholder text to be displayed on the text box when the user hasn't typed any text yet.
DefaultInputstringfalseThe initial text to place in the text box. Leave this null for a blank text box.

ToastSelectionBox

Implements IToastInput

A selection box control, which lets users pick from a dropdown list of options.

PropertyTypeRequiredDescription
IdstringtrueThe Id is required. If the user selected this item, this Id will be passed back to your app's code, representing which selection they chose.
ContentstringtrueContent is required, and is a string that is displayed on the selection item.

ToastSelectionBoxItem

A selection box item (an item that the user can select from the drop down list).

PropertyTypeRequiredDescription
IdstringtrueThe Id is required, and is used to map the user-inputted text into a key-value pair of id/value which your app later consumes.
TitlestringfalseTitle text to display above the selection box.
DefaultSelectionBoxItemIdstringfalseThis controls which item is selected by default, and refers to the Id property of the ToastSelectionBoxItem. If you do not provide this, the default selection will be empty (user sees nothing).
ItemsIListfalseThe selection items that the user can pick from in this SelectionBox. Only 5 items can be added.

IToastButton

Marker interface for toast buttons.

Implementations
ToastButton
ToastButtonSnooze
ToastButtonDismiss

ToastButton

Implements IToastButton

A button that the user can click.

PropertyTypeRequiredDescription
ContentstringtrueRequired. The text to display on the button.
ArgumentsstringtrueRequired. App-defined string of arguments that the app will later receive if the user clicks this button.
ActivationTypeToastActivationTypefalseControls what type of activation this button will use when clicked. Defaults to Foreground.
ActivationOptionsToastActivationOptionsfalseNew in Creators Update: Gets or sets additional options relating to activation of the toast button.

ToastActivationType

Decides the type of activation that will be used when the user interacts with a specific action.

ValueMeaning
ForegroundDefault value. Your foreground app is launched.
BackgroundYour corresponding background task (assuming you set everything up) is triggered, and you can execute code in the background (like sending the user's quick reply message) without interrupting the user.
ProtocolLaunch a different app using protocol activation.

ToastActivationOptions

New in Creators Update: Additional options relating to activation.

PropertyTypeRequiredDescription
AfterActivationBehaviorToastAfterActivationBehaviorfalseNew in Fall Creators Update: Gets or sets the behavior that the toast should use when the user invokes this action. This only works on Desktop, for ToastButton and ToastContextMenuItem.
ProtocolActivationTargetApplicationPfnstringfalseIf you are using ToastActivationType.Protocol, you can optionally specify the target PFN, so that regardless of whether multiple apps are registered to handle the same protocol uri, your desired app will always be launched.

ToastAfterActivationBehavior

Specifies the behavior that the toast should use when the user takes action on the toast.

ValueMeaning
DefaultDefault behavior. The toast will be dismissed when the user takes action on the toast.
PendingUpdateAfter the user clicks a button on your toast, the notification will remain present, in a 'pending update' visual state. You should immediately update your toast from a background task so that the user does not see this 'pending update' visual state for too long.

ToastButtonSnooze

Battle net linux. Implements IToastButton

A system-handled snooze button that automatically handles snoozing of the notification.

PropertyTypeRequiredDescription
CustomContentstringfalseOptional custom text displayed on the button that overrides the default localized 'Snooze' text.

ToastButtonDismiss

Implements IToastButton

A system-handled dismiss button that dismisses the notification when clicked.

PropertyTypeRequiredDescription
CustomContentstringfalseOptional custom text displayed on the button that overrides the default localized 'Dismiss' text.

ToastActionsSnoozeAndDismiss

*Implements IToastActions Pdf expert edit and sign pdf 2 2 17.

Automatically constructs a selection box for snooze intervals, and snooze/dismiss buttons, all automatically localized, and snoozing logic is automatically handled by the system.

PropertyTypeRequiredDescription
ContextMenuItemsIListfalseNew in Anniversary Update: Custom context menu items, providing additional actions if the user right clicks the notification. You can only have up to 5 items.

ToastContextMenuItem

A context menu item entry.

PropertyTypeRequiredDescription
ContentstringtrueRequired. The text to display.
ArgumentsstringtrueRequired. App-defined string of arguments that the app can later retrieve once it is activated when the user clicks the menu item.
ActivationTypeToastActivationTypefalseControls what type of activation this menu item will use when clicked. Defaults to Foreground.
ActivationOptionsToastActivationOptionsfalseNew in Creators Update: Additional options relating to activation of the toast context menu item.

ToastAudio

Specify audio to be played when the Toast notification is received.

PropertyTypeRequiredDescription
SrcurifalseThe media file to play in place of the default sound. Only ms-appx and ms-appdata are supported.
LoopbooleanfalseSet to true if the sound should repeat as long as the Toast is shown; false to play only once (default).
SilentbooleanfalseTrue to mute the sound; false to allow the toast notification sound to play (default).

ToastHeader

New in Creators Update: A custom header that groups multiple notifications together within Action Center.

PropertyTypeRequiredDescription
IdstringtrueA developer-created identifier that uniquely identifies this header. If two notifications have the same header id, they will be displayed underneath the same header in Action Center.
TitlestringtrueA title for the header.
ArgumentsstringtrueGets or sets a developer-defined string of arguments that is returned to the app when the user clicks this header. Cannot be null.
ActivationTypeToastActivationTypefalseGets or sets the type of activation this header will use when clicked. Defaults to Foreground. Note that only Foreground and Protocol are supported.
ActivationOptionsToastActivationOptionsfalseGets or sets additional options relating to activation of the toast header.

Related topics





broken image