AppNotificationBuilder.AddArgument(String, String) Method

Definition

Adds an argument composed of a key/value pair to the XML payload for an app notification.

public:
 virtual AppNotificationBuilder ^ AddArgument(Platform::String ^ key, Platform::String ^ value) = AddArgument;
AppNotificationBuilder AddArgument(winrt::hstring const& key, winrt::hstring const& value);
public AppNotificationBuilder AddArgument(string key, string value);
function addArgument(key, value)
Public Function AddArgument (key As String, value As String) As AppNotificationBuilder

Parameters

key
String

Platform::String

winrt::hstring

A string containing the key of the argument.

value
String

Platform::String

winrt::hstring

A string containing the value of the argument.

Returns

Returns the AppNotificationBuilder instance so that additional method calls can be chained.

Examples

The following example shows the usage of this method to add arguments to an app notification.

var notification = new AppNotificationBuilder()
    .AddText("Send a message.")
    .AddTextBox("textBox")
    .BuildNotification();

AppNotificationManager.Default.Show(notification);

The resulting XML payload:

<toast launch='key=value'>
    <visual>
        <binding template='ToastGeneric'>
            <text>Notification text.</text>
        </binding>
    </visual>
</toast>

Remarks

App notification arguments added with this method are passed to the activated application when the user clicks on the notification. You can add multiple arguments to each notification. Retrieve the arguments added with this method by accessing the AppNotificationActivatedEventArgs.Arguments property.

For guidance on using the AppNotificationBuilder APIs to create the UI for app notifications, see App notification content.

For reference information about the XML schema for app notifications, see App notification content schema.

Applies to