Believe2014
Believe2014

Reputation: 3964

Why is the toast message not shown?

In a windows 8.1 app, I am trying to make a toast notification using the code:

public class ToastController
{
    #region Public Methods and Operators

    /// <summary>
    /// The show.
    /// </summary>
    /// <param name="message">
    /// The message.
    /// </param>
    public void Show(string message)
    {
        // A single string wrapped across three lines of text.
        XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastImageAndText01);

        toastXml.GetElementsByTagName("text").First().InnerText = message;
        var toast = new ToastNotification(toastXml);

        ToastNotifier notifier = ToastNotificationManager.CreateToastNotifier();
        notifier.Show(toast);
    }

    #endregion
}

But I cannot see any toast messages at all when the Show() method is invoked. Am I missing anything?


Update: I have been able to get the toast message to show when debugging the windows app using Local Machine. However, the toast message is still not shown when launch in Simulator. Help please.


Upvotes: 0

Views: 358

Answers (1)

Believe2014
Believe2014

Reputation: 3964

It turns out that I need to set up my app to enable toast notification:

<VisualElements 
    ...
    ToastCapable="true">
</VisualElements>

https://msdn.microsoft.com/en-us/library/windows/apps/hh781238.aspx

Upvotes: 2

Related Questions